home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 60.zip / BS1 part 60 / LSD 31.adf / AmigaMachineLang3.pp / AmigaMachineLang3
Text File  |  1990-09-07  |  174KB  |  3,842 lines

  1.               _____          _________________________________
  2.              /    /\        /                                 \
  3.             /    / /       /    ___________________________    \
  4.            /    / /       /    / _________________________/\    \
  5.           /    / /       /    /_/___________      _____   \ \    \
  6.          /    / /       /                   \    /\    \   \ \    \
  7.         /    / /       /_________________    \   \ \    \   \ \    \
  8.        /    / /        \________________/\    \   \ \    \   \ \    \
  9.       /    /_/__________________________\_\    \   \ \    \___\/     \
  10.      /                                          \   \ \              / 
  11.     /____________________________________________\   \ \____________/
  12.     \____________________________________________/    \/___________/FISH
  13.  
  14.                                 P R E S E N T
  15.  
  16.                  AMIGA MACHINE LANGUAGE - FROM ABACUS BOOKS
  17.  
  18.                                P A R T  I I I
  19.  
  20.  
  21.                      Typed by DEE JAY of X-CELL for LSD
  22.                       Extra text by Pazza and Muridae
  23.  
  24.  
  25.  
  26.       Chapter 7.
  27.       ----------
  28.       7.Working With Intuition.
  29.       -------------------------
  30.         Now that you've learned so much about machine language,lets look
  31.         at the special features of the Amiga.Lets look at the operating
  32.         system Intuition that is in charge of windows,screens,the mouse
  33.         and lots of other things.Beforetaking a look at these beautiful   
  34.         features,theres some bad news.
  35.         First,though,lets here the good news.Since Intuition has so many
  36.         functions,it allows you to be very creative in programming your
  37.         ideas.The disadvantage is that the flexibility means that you have
  38.         to use a lot of parameters,and that makes for a lot of tedious
  39.         work.
  40.         However,this is no grounds for panic.Once you've built up the
  41.         necessary routines,the programming and experimentation becomes
  42.         increasingly interesting.Before you try out new program variations
  43.         you should save your source code to disk,because Intuition gets
  44.         fairly upset about bad parameters and often responds by crashing
  45.         the system.
  46.         Now lets get to work.To start working with Intuition,you need the 
  47.         Intuition library.You can load it with the OpenLibrary function
  48.         from the EXEC library.Heres the subroutine that takes care of
  49.         initialization.
  50.  
  51.         openlib   =-408
  52.         execbase  = 4
  53.  
  54.         run:
  55.                bsr     openint         ;load intuition library
  56.                ...
  57.  
  58.         openint:                       ;*initialize and open system
  59.                move.l  execbase,a6     ;exec base address 
  60.                lea     intname,a1      ;name of intuition library
  61.                jsr     openlib(a6)     ;open intuition
  62.                move.l  d0,intbase      ;save intuition base address
  63.                rts
  64.  
  65.         intname: dc.b "intuition.library",0
  66.                align
  67.         intbase: dc.l 0                ;base address of intuition
  68.  
  69.         When your program is finished,you need to close the screens,the
  70.         window and the library.To do this,use the CloseLibrary function
  71.         from the EXEC library.It has an offset of -414.
  72.         Heres the subroutine:
  73.  
  74.         closelibrary  =-414
  75.                ...
  76.         closeint:                        ;*close intuition
  77.                move.l  execbase,a6       ;exec base address in A6
  78.                move.l  intbase,a1        ;intuition base address in A1
  79.                jsr     closelibrary(a6)  ;close intuition
  80.                rts                       ;done
  81.  
  82.         Now that you've got that taken care of,you can finally start
  83.         working with Intuition.
  84.  
  85.       7.1.Open Screen.
  86.       ----------------
  87.         Intuition is a graphics operating system.For this reason,you'll be
  88.         working with the screen.Its even more interesting to work with
  89.         several screens at the same time.However,you only have one monitor
  90.         on the Amiga.
  91.         You can open as many screens as you like (at least,as long as
  92.         theres some memory available).You can open a window,display menus
  93.         and do I/O's there.The individual screens are fully independant.
  94.         You can work with all of them simultaneously on the monitor.
  95.         You can move individual screens forward and back to your hearts
  96.         content.You can also press the left <Amiga> key and then an "m"to
  97.         return to the workbench screen after getting into the different
  98.         screens.
  99.         You want to begin programming Intuition by setting up a screen.You
  100.         have already loaded the Intuition library,so you can use the Open-
  101.         Screen function.
  102.         Wait a minute!What should the screen look like,where should it go,
  103.         and what form should it have?You need to look at the options for
  104.         the form of the screen you have available.
  105.         The input to the screen is in the form of a table that has 13
  106.         entries.Lets take a look at the parameters that you need for our
  107.         screen.
  108.         You'll start the table with the label "screen_defs"which must be
  109.         at an even address:
  110.  
  111.                align
  112.         screen_defs:                 ;The screen table begins here
  113.  
  114.         The first bit of information that the screen needs is the position
  115.         and size.Lets have it start in the upper left corner and fill the
  116.         entire screen.You'll use the positions X=0 and Y=0,the width 320
  117.         and the height 200.This means that your screen is the maximum
  118.         size.
  119.  
  120.         x_pos:     dc.w   0        ;X-Position
  121.         y_pos:     dc.w   0        ;Y-Position
  122.         width:     dc.w   320      ;width
  123.         height:    dc.w   200      ;height
  124.  
  125.         Next you need to decide which colors should be displayed.That
  126.         depends on the number of bitplanes,on the depth.Lets choose two.  
  127.         That means you have 2^2 (4) colours available.Lets choose two,
  128.         since four colours is usually plenty.
  129.  
  130.         depth:     dc.w   2        ;number of bitplanes
  131.  
  132.         Next you need to choose the colour of the title line and the
  133.         function symbols.Give the number of the colour register:
  134.  
  135.         detail_pen:  dc.b   0      ;colour of text,etc...
  136.  
  137.         Now for the colour of the text background:
  138.  
  139.         block_pen    dc.b   1      ;background colour
  140.  
  141.         Make sure that these two inputs fit in a byte.The colours are
  142.         normally the following (if the standard values have'nt been
  143.         changed).You'll notice that the number of colours depends on the
  144.         number of bit maps.
  145.  
  146.             Pen        Colour
  147.          ---------------------------------------------------------
  148.              0         Background (blue)
  149.              1         White
  150.           for two bit planes
  151.              2         Black
  152.              3         Red
  153.           for three bit planes
  154.              4         Blue
  155.              5         Violet
  156.              6         Turquoise
  157.              7         White
  158.           for four bit planes
  159.              8         Black
  160.              9         Red
  161.             10         Green
  162.             11         Brown
  163.             12         Blue
  164.             13         Blue
  165.             14         Green
  166.             15         Green
  167.  
  168.         The next word contains the bits that describe the appearance of
  169.         the screen.The bits are:
  170.  
  171.         Bit    Value    Name             Meaning
  172.         ---------------------------------------------------------------  
  173.          1       2      GENLOCK_VIDEO    
  174.          2       4      INTERLACE        Puts the screen in Interlace
  175.                                          mode.The resolution and thus the 
  176.                                          maximum screen size are doubled.
  177.          6     $40      PFBA
  178.          7     $80      EXTRA_HALFBRITE
  179.          8     $100     GENLOCL_AUDIO
  180.         10     $400     DBLPF            Divides the screen into a border
  181.         and                              character area.
  182.         11     $800     HOLDNMODIFY      Turns on Hold-and-Modify mode.
  183.         13     $2000    VP_HIDE
  184.         14     $4000    SPRITES          Allows sprites to be used.
  185.         15     $8000    MODE_640         Turns on the highest resolution  
  186.                                          graphics for the screen(640x400).
  187.  
  188.         Choose the value two (normal) for your example screen:
  189.  
  190.         view_modes:  dc.w   2         ;representation mode
  191.  
  192.         The following word is constructed in such away that each bit as
  193.         its own meaning.Use this to set what sort of screen it is.Choose
  194.         15 so the screen is a "Custom screen",which allows you all of the 
  195.         options.
  196.  
  197.         screen_type:  dc.w  15      ;screen type:custom screen
  198.  
  199.         Next theres a pointer to the character set to be used for all
  200.         output to the screen.If you don't want to install your own
  201.         character set,just put a zero here,and the standard character set 
  202.         is used.
  203.  
  204.         font:   dc.l  0         ;character set:standard
  205.  
  206.         Next theres a pointer to the text thats used as the name of the
  207.         screen.The text ends with a zero,just like window names must. 
  208.  
  209.         title:  dc.l  name      ;pointer to title text
  210.  
  211.         Next comes a long word that defines the gadgets.These gadgets
  212.         represent the functions,like "Bring forward",that can be accessed 
  213.         via a mouse click in the screen.The long word in this table is a
  214.         pointer to a list which specifies the gadgets.These aren't the
  215.         system gadgets.However,you're only using system gadgets here,so
  216.         put a zero here.
  217.  
  218.         gadgets:  dc.l  0        ;no gadgets
  219.  
  220.         Finally theres a long word that you only need if you want to use
  221.         the special bitmap just for your screen.Since this isn't the case,
  222.         just put a zero here.
  223.  
  224.         bitmap:  dc.l  0         ;no bitmap
  225.  
  226.         Thats it for the list entries that you need to define the screen. 
  227.         You still need the text for the name of the screen.Enter the
  228.         following:
  229.  
  230.         sname:   dc.b  'Our Screen',0    ;screen title
  231.  
  232.         Heres a quick overview of the list:
  233.  
  234.                align
  235.         screen_defs:                  ;*The screen ta
  236.         x_pos:        dc.w  0         ;X-position
  237.         y_pos:        dc.w  0         ;Y-position
  238.         width:        dc.w  320       ;width
  239.         height:       dc.w  200       ;height
  240.         depth:        dc.w  2         ;number of bitplanes
  241.         detail_pen:   dc.b  0         ;colour of the text,etc...
  242.         block_pen:    dc.b  1         ;background colour
  243.         view_modes:   dc.w  2         ;representation mode
  244.         screen_type:  dc.w  15        ;screen type:custom screen
  245.         font:         dc.l  0         ;character set:standard
  246.         title:        dc.l  sname     ;pointer to title text
  247.         gadgets:      dc.l  0         ;no gadgets
  248.         bitmap:       dc.l  0         ;no bit map
  249.         sname:        dc.b  'Our Screen',0  ;screen title
  250.  
  251.         Once you've decided on the parameters,its very easy to open the
  252.         screen.You need Intuitions OpenScreen function.Its offset is -198 
  253.         and it only needs one parameter,the address of the parameter
  254.         table.The program fragment looks like this:
  255.  
  256.         openscreen =-198
  257.                bsr     openint            ;open intuition
  258.                bsr     scropen            ;open screen
  259.                ...
  260.         scropen:                          ;*open screen
  261.                move.l  intbase,a6         ;intuition base address in A6
  262.                lea     screen_defs,a0     ;pointer to table
  263.                jsr     openscreen(a6)     ;and open
  264.                move.l  d0,screenhd        ;save screen handle
  265.                rts                        ;return to main program
  266.                ...
  267.         screen_defs:                      ;table info follows
  268.  
  269.         Now the Amigas Workbench screen is covered by your screen.Now you 
  270.         can do what you want with it until the program is done.Afterwards,
  271.         the screen must be closed again,so that you can see the Workbench 
  272.         screen again.
  273.         Use the CloseScreen function (offset -66) to do this.The only
  274.         parameter it needs is the pointer to the screen structure you got 
  275.         back from the OpenScreen function.
  276.  
  277.         closescreen =-66
  278.                ...
  279.         scrclose:                         ;* close screen
  280.                move.l  intbase,a6         ;intuition base address in A6
  281.                move.l  screenhd,a0        ;screen handle in A0
  282.                jsr     closescreen(a6)    ;clos screen
  283.                rts                        ;done
  284.  
  285.         The long word that OpenScreen returned to you is a pointer to a
  286.         screen structure that contains all the needed data about the
  287.         screen.Besides the data which was given,there is a pointer in the 
  288.         screen area for individual bit planes,etc...
  289.         The form of this structure is fairly complicated and contains some
  290.         data that you can't use.Several of the parameters are interesting,
  291.         however.Heres a selection of usable parameters:
  292.  
  293.         No    Name              Function
  294.         ------------------------------------------------------------------
  295.         0     (NextScreen.L)    Pointer to next screen.
  296.         4     (FirstWindow)     Pointer to first window structure
  297.         8     (LeftEdge.W)      
  298.         $A    (TopEdge.W)       Position of screen
  299.         $C    (Width.W)         Width
  300.         $E    (Height.W)        Height
  301.         $10   (MouseY.W)
  302.         $12   (MouseX.W)        Mouse position in the screen
  303.         $14   (Flags.W)         Screen flags
  304.         $16   (Title.L)         Pointer to title text
  305.         $1A   (DefaultTitle)    Pointer to normal title
  306.         $28   (Font.L)          Pointer to character set
  307.         $C0   (Plane0.L)        Pointer to bitplane 0
  308.         $C4   (Plane1.L)        Pointer to bitplane 1
  309.         $C8   (Plane2.L)        Pointer to bitplane 2
  310.         $CC   (Plane3.L)        Pointer to bitplane 3
  311.  
  312.         An example of an application for the plane pointer is writing and 
  313.         using your own character routine.Next you want to move the address
  314.         of the plane into an address register as follows:
  315.  
  316.                move.l  screenhd,a5        ;screen pointer in A5
  317.                move.l  $c0(a5),a5         ;bitplane 0-pointer in A5
  318.  
  319.         If you want to try this,do the following:
  320.  
  321.                move.l  screenhd,a5        ;screen pointer in A5
  322.                move.l  $c0(a5),a5         ;bitplane 0-pointer in A5
  323.                move    #$20,d0            ;Counter D0=$20
  324.  
  325.         lop1:
  326.                move    d0,(a5)            ;write counter bits in picture
  327.                add.l   #80,a5             ;address+80,next line
  328.                dbra    d0,lop1            ;continue until D0 < 0
  329.  
  330.         This program draws a white,square pattern that corresponds to the 
  331.         bit pattern for the numbers $20 to 0.This isn't a particularly
  332.         useful program,but it shows how easy it is to write from a machine
  333.         language program directly to the screen.If you change the offset
  334.         in the second line to $C4,the pattern is read.
  335.         You can move the entire screen with the normal technique of moving
  336.         the mouse pointer into the upper border and moving it up and down 
  337.         with the left mouse key depressed.You can do the same with a
  338.         program.
  339.         Lets move the screen without the mouse.Use the joystick for
  340.         demonstration purposes.Put the joystick in port two.As you saw in
  341.         the chapter on the hardware register,you can read memory location 
  342.         $DFF00C to find information about the joystick.You can find the
  343.         direction the screen should be moved here.
  344.         Moving the screen requires another Intuition function.You use the 
  345.         MoveScreen function which as an offset of -162 and needs three
  346.         parameters to do this.The parameters are:
  347.  
  348.         In A0   the pointer to the screen structure that you got back in
  349.                 D0 when you opened the screen.(You saved it in "screenhd")
  350.         In D1   the desired movement in the Y-direction,the vertical
  351.                 direction.
  352.         In D0   the horizontal movement in the X-direction.The varient
  353.                 doesn't work so you can only move the screen vertically.
  354.  
  355.         Insert the following lines in your program:
  356.  
  357.         MoveScreen =-162
  358.                ...
  359.         scrmove:                          ;*move screen D0 to the right
  360.                                           ;and D1 down
  361.                move.l  intbase,a6         ;intuition base address in A6
  362.                move.l  screenhd,a0        ;screen handle in A0
  363.                clr.l   d0                 ;no horizontal movement
  364.                jsr     movescreen(a6)     ;move screen
  365.                rts                        ;done
  366.  
  367.         Now your looking at a complete program that goes through the
  368.         following steps:
  369.  
  370.         1.  Opens the Intuition library
  371.         2.  Opens the screen
  372.         3.  Moves the screen in the direction specified by the joystick in
  373.             port two
  374.         4.  Closes the screen when the fire button is hit
  375.         5.  Closes the Intuition library
  376.         6.  Ends
  377.  
  378.         Here is the complete program including the subroutines,so you'll
  379.         have it all in one spot:
  380.  
  381.         ;** Demo program to open and move a screen **
  382.  
  383.         movescreen   =-162
  384.         openscreen   =-198
  385.         closescreen  =-66
  386.         closelibrary =-414
  387.         openlib      =-408                ;open library
  388.         execbase     = 4                  ;exec base address
  389.         joy2         =$dff00c             ;joystick 2 data
  390.         fire         =$bfe001             ;firebutton 2:bit 7
  391.  
  392.         run:
  393.                bsr     openint            ;open intuition
  394.                bsr     scropen            ;open screen
  395.                move    joy2,d6            ;save joystick info
  396.  
  397.         loop:
  398.                tst.b   fire               ;test fire button
  399.                bpl     ende               ;pressed down:done
  400.                move    joy2,d0            ;basic info in D0
  401.                sub     d6,d0              ;subtract new data
  402.                cmp     #$0100,d0          ;up?
  403.                bne     noup               ;no
  404.                move.l  #-1,d1             ;dy=-1 direction y
  405.                bsr     scrmove            ;move up
  406.                bra     loop
  407.  
  408.         noup:
  409.                cmp     #$0001,d0          ;down?
  410.                bne     loop               ;no
  411.                move.l  #1,d1              ;dy=1
  412.                bsr     scrmove            ;move down
  413.                bra     loop
  414.  
  415.         ende:
  416.                bsr     scrclose           ;close screen
  417.                bsr     closeint           ;close intuition
  418.                rts                        ;done!
  419.  
  420.         openint:                          ;*initialize and open system
  421.                move.l  execbase,a6        ;exec base address
  422.                lea     intname,a1         ;name of intuition library
  423.                jsr     openlib(a6)        ;open intuition
  424.                move.l  d0,intbase         ;save intuition base address
  425.                rts
  426.  
  427.         closeint:                         ;*close intuition
  428.                move.l  execbase,a6        ;exec base address in A6
  429.                move.l  intbase,a1         ;intuition base address in A1
  430.                jsr     closelibrary(a6)   ;close intuition
  431.                rts                        ;done
  432.  
  433.         scropen:                          ;*open screen
  434.                move.l  intbase,a6         ;intuition base address in A6
  435.                lea     screen_defs,a0     ;pointer to table
  436.                jsr     openscreen(a6)     ;open
  437.                move.l  d0,screenhd        ;save screen handle
  438.                rts                        ;return to main program
  439.  
  440.         scrclose:                         ;*close screen
  441.                move.l  intbase,a6         ;intuition base address in A6
  442.                move.l  screenhd,a0        ;screen handle in A0
  443.                jsr     closescreen(a6)    ;close screen
  444.                rts                        ;done
  445.  
  446.         scrmove:                          ;move screen D0 right/D1 down
  447.                move.l  intbase,a6         ;intuition base address in A6
  448.                move.l  screenhd,a0        ;screen handle in A0
  449.                clr.l   d0                 ;no horizontal movement
  450.                jsr     movescreen(a6)     ;and move
  451.                rts                        ;done
  452.                align
  453.  
  454.         screen_defs:                      ;*screen table begins here
  455.         x_pos:         dc.w  0            ;X-position
  456.         y_pos:         dc.w  0            ;Y-position
  457.         width:         dc.w  320          ;width
  458.         height:        dc.w  200          ;height
  459.         depth:         dc.w  2            ;number of bitplanes
  460.         detail_pen:    dc.b  1            ;Text colour=white
  461.         block_pen:     dc.b  3            ;background colour=red
  462.         view_modes:    dc.w  2            ;representation mode
  463.         screen_type    dc.w  15           ;screen type:custom screen
  464.         font:          dc.l  0            ;standard character set
  465.         title:         dc.l  sname        ;pointer to title text
  466.         gadgets:       dc.l  0            ;no gadgets
  467.         bitmap:        dc.l  0            ;no bit map
  468.         intbase:       dc.l  0            ;base address of intuition
  469.         screenhd:      dc.l  0            ;screen handle
  470.         intname:       dc.b  'intuition.library',0
  471.                align
  472.         sname:         dc.b  'Our Screen',0   ;Screen title
  473.                align
  474.                end
  475.  
  476.         From this example,you can see how easy scrolling actually is.     
  477.         Another easy thing to do is to use the DisplayBeep function.It as 
  478.         an offset -96;the only parameter it needs is the screen pointer
  479.         that you stored in the "screenhd"memory block.This function covers
  480.         the screen with an orange colour for a short while.The screen is  
  481.         not changed.The beep function can be used as follows:
  482.  
  483.         DisplayBeep: =-96
  484.                ...
  485.                move.l  intbase,a6         ;intuition base address in A6
  486.                move.l  screenhd,a0        ;screen pointer in A0
  487.                jsr     displaybeep(a6)    ;light up screen
  488.  
  489.         If you put a zero instead of a screen pointer in A0,the whole
  490.         screen blinks.
  491.         Good,now you have your own screen that you can move up and down.  
  492.         What good is it if you can't put anything on it?Lets open a window
  493.         on the screen!
  494.  
  495.       7.2.Open Window.
  496.       ----------------
  497.         As you saw in the chapter on program initialization,its easy to
  498.         open a window with the DOS library.You can't use this method on
  499.         your own screen however.You need to use another method that can
  500.         open any window on any screen.
  501.         Intuition has a function called OpenWindow which handles this sort
  502.         of work.It has an offset of -204 and needs only one parameter,a
  503.         pointer to a window definition table.This pointer goes in register
  504.         A0.
  505.         This table is very similar to the one used to define the screen.  
  506.         The first four values specify the X-and Y-positions,the width,and
  507.         the height of the window to be opened.Heres an example:
  508.  
  509.                align
  510.         window_defs:
  511.                        dc.w  10           ;x-position
  512.                        dc.w  20           ;y-position
  513.                        dc.w  300          ;width
  514.                        dc.w  150          ;height
  515.  
  516.         Next come two bytes that define the colour of the letters on the  
  517.         background:
  518.  
  519.                        dc.b  1            ;white letter colour
  520.                        dc.b  3            ;on a red background
  521.  
  522.         The next long word contains the IDCMP flags in its bits.The bits  
  523.         determine the circumstances under which Intuition sends a message 
  524.         to the program.The bits have the following meanings:
  525.  
  526.         Bit  Value     Name             Meaning
  527.         -----------------------------------------------------------------
  528.          0   $000001   SIZEVERIFY
  529.          1   $000002   NEWSIZE          Window size changed
  530.          2   $000004   REFRESHWINDOW
  531.          3   $000008   MOUSEBUTTONS     Mouse key hit
  532.          4   $000010   MOUSEMOVE        Mouse moved
  533.          5   $000020   GADGETDOWN       A special gadget chosen
  534.          6   $000040   GADGETUP         Same as above
  535.          7   $000080   REQSET
  536.          8   $000100   MENUPICK         A menu item chosen
  537.          9   $000200   CLOSEWINDOW      A window closed
  538.         10   $000400   RAWKEY           A key pressed
  539.         11   $000800   REQVERIFY
  540.         12   $001000   REQCLEAR
  541.         13   $002000   MENUVERIFY
  542.         14   $004000   NEWPREFS         Preferences modified
  543.         15   $008000   DISKINSERTED     A disk put in
  544.         16   $010000   DISKREMOVED      A disk taken out
  545.         17   $020000   WBENCHMESSAGE
  546.         18   $040000   ACTIVEWINDOW     A window activated
  547.         19   $080000   INACTIVEWINDOW   A window deactivated
  548.         20   $100000   DELTAMOVE        Report relative mouse movement
  549.  
  550.         If you want your first window to respond only by clicking on the
  551.         close symbol,write the following:
  552.  
  553.             dc.l  $200   ;IDCMP flags:CLOSEWINDOW
  554.  
  555.         Next comes a long word whose bits determine the windows type.You  
  556.         can use this to construct a window to your exact specifications.  
  557.         This is quite different from windows opened with the DOS function.
  558.         The bits mean:
  559.  
  560.         Bit  Value     Name             Meaning
  561.         ------------------------------------------------------------------
  562.          0   $0000001  WINDOWSIZING     Window size is changeable
  563.          1   $0000002  WINDOWDRAG       Window is moveable
  564.          2   $0000004  WINDOWDEPTH      Window covering is posible
  565.          3   $0000008  WINDOWCLOSE      Window close symbol
  566.          4   $0000010  SIZEBRIGHT
  567.          5   $0000020  SIZEBOTTOM
  568.          6   $0000040  SIMPLE_REFRESH   New drawing manuel
  569.          7   $0000080  SUPER_BITMAP     Save the windows contents
  570.          8   $0000100  BACKDROP         Move window back
  571.          9   $0000200  REPORTMOUSE      Report mouse co-ordinates
  572.         10   $0000400  GIMMEZEROZERO
  573.         11   $0000800  BORDERLESS       Window without border
  574.         12   $0001000  ACTIVATE         Window active
  575.         13   $0002000  WINDOWACTIVATE
  576.         14   $0004000  INREQUEST
  577.         15   $0008000  MENUSTATE
  578.         16   $0010000  RMBTRAP          Right mouse key:no menu
  579.         17   $0020000  NOCAREREFRESH    No refresh message
  580.         24   $1000000  WINDOWREFRESH
  581.         25   $2000000  WBENCHWINDOW
  582.  
  583.         To refresh is to rebuild the window contents when necessary,for
  584.         instance when the windows size is changed.If none of the refresh
  585.         bits are set,you're in Smart-Refresh-Mode.In this case,Intuition
  586.         takes care of refreshing the window.This is the easiest method.
  587.         If you choose the value $100F as the type for your example window,
  588.         the window is active once its opened,and it has all the system
  589.         gadgets:
  590.  
  591.              dc.l   $100F       ;ACTIVATE and all gadgets
  592.  
  593.         The next long word in the list allows you to use your own gadgets
  594.         in the window.This long word is a pointer to the structure of a
  595.         your gadget.Since you don't want this,just put a zero here.
  596.  
  597.              dc.l   0           ;first gadget:no gadgets of our own
  598.  
  599.         The next long word is a pointer to a graphics structure so you can
  600.         design your own symbol for checking menu points.Put a zero here.
  601.         You'll use the standard sign:
  602.  
  603.              dc.l   windowname  ;pointer to window name
  604.  
  605.         The next long word is a pointer to the screen structure that you
  606.         got back after calling the OpenScreen function.The easiest way to
  607.         do this is to save the pointer to this location in the buffer:
  608.  
  609.         screenhd:   dc.l 0   ;screen pointer
  610.  
  611.         The next long word is a pointer to a bit map if you want one of
  612.         your own for the window.Since you don't want one,put a zero here.
  613.  
  614.                 dc.l  0        ;no bit map of our own
  615.  
  616.         Next come four values that set the maximum and minimum width and  
  617.         height of the window:
  618.  
  619.                 dc.w  150      ;smallest width
  620.                 dc.w  50       ;smallest height
  621.                 dc.w  320      ;maximum width
  622.                 dc.w  200      ;maximum height
  623.  
  624.         The last value in the list is the screen type of the screen the
  625.         window is located in.Put a 15 here.You're using our screen as a   
  626.         custom screen:
  627.  
  628.                 dc.w  15       ;screen type:custom screen
  629.  
  630.         Heres a quick overview of the whole list:
  631.  
  632.             align
  633.         window_prefs:
  634.                       dc.w   10           ;X-position
  635.                       dc.w   20           ;Y-position
  636.                       dc.w   300          ;width
  637.                       dc.w   150          ;height
  638.                       dc.b   1            ;white print colour
  639.                       dc.b   3            ;on red background
  640.                       dc.l   $200         ;IDCMP flags:CLOSEWINDOW
  641.                       dc.l   $100f        ;ACTIVATE and all gadgets
  642.                       dc.l   0            ;first gadget:no gadgets of
  643.                                           ;our own
  644.                       dc.l   0            ;checkmark:standard
  645.                       dc.l   windowname   ;pointer to window name
  646.         screenhd:     dc.l   0            ;screen pointer
  647.                       dc.l   0            ;no bitmap of our own
  648.                       dc.w   150          ;smallest width
  649.                       dc.w   50           ;smallest height
  650.                       dc.w   320          ;maximum width
  651.                       dc.w   200          ;maximum height
  652.                       dc.w   15           ;screen type:custom screen
  653.  
  654.         ;and here comes the window name:
  655.         windowname:   dc.b   'Our Window',0
  656.             align
  657.  
  658.         Insert these lines in the program you listed above.Here are two   
  659.         subroutines for opening and closing the window:
  660.  
  661.         openwindow  =-204
  662.         closewindow =-72
  663.                ...
  664.         windopen:
  665.                move.l  intbase,a6        ;intuition base address in A6
  666.                lea     windowdef,a0      ;pointer to window definition
  667.                jsr     openwindow(a6)    ;open window
  668.                move.l  d0,windowhd       ;save window handle
  669.                rts
  670.  
  671.         windclose:
  672.                move.l  intbase,a6        ;intuition base address in A6
  673.                move.l  windowhd,a0       ;window handle
  674.                jsr     closewindow(a6)   ;close window
  675.                rts
  676.                ...
  677.         windowhd:      dc.l   0          ;window handle
  678.  
  679.         Now you can insert a "bsr windowopen"after the "bsr scropen"and a 
  680.         "bsr windclose"before the "bsr scrclose"command.Once you've
  681.         started the program,move the window around in the screen.You'll
  682.         find that you can't move the window out of the screen with the
  683.         mouse. 
  684.         The window in the example has the close gadget in the upper left
  685.         corner.Normally if you click it,the window is closed.Try clicking
  686.         it.You'll find that nothing happens.
  687.         The display of this and all other gadgets,as well as other events
  688.         must be programmed in,since Intuition doesn't know which action
  689.         causes which event.We'll take a look at how to handle this in the 
  690.         next chapter.
  691.  
  692.       7.3.Requesters.
  693.       ---------------
  694.         If you only have one disk drive,you've certainly seen the Amiga   
  695.         message,"Please insert xxx in unit 0",a lot.This window is another
  696.         that has two fields for clicking.This sort of message with a
  697.         choice of options is called a requester.                          
  698.         You want to take a look at how to program a requester.First,you
  699.         need a window for the requester to appear in.You opened a window
  700.         of this sort in the example program.
  701.         To display a requester,use the Intuition function AutoRequest
  702.         (offset -348).It takes care of drawing and managing the requester.
  703.         This function needs the following parameters:
  704.  
  705.         In A0   The pointer to the window structure that you put in
  706.                 "windowhd".
  707.         In A1   A pointer to the text structure that should stand over the 
  708.                 choice buttons.
  709.         In A2   Same as above for the text of the left button.
  710.         In A3   Same as above for the right button.
  711.         In D0   The IDCMP flag which lets you know what event should go
  712.                 with the clicking of the left button.
  713.         In D1   Same as above for the right button.
  714.         In D2   The width of the whole requester.
  715.         In D3   The height of the requester.
  716.  
  717.         Insert the following lines in your program:
  718.  
  719.         autorequest =-348
  720.                ...
  721.         request:
  722.                move.l  windowhd,a0       ;pointer to window structure
  723.                lea     btext,a1          
  724.                lea     ltext,a2          ;pointer to text structure
  725.                lea     rtext,a3        
  726.                move.l  #0,d0             ;left activates by clicking
  727.                move.l  #0,d1             ;right activates by clicking
  728.                move.l  #180,d2           ;width and
  729.                move.l  #80,d3            ;height of requester
  730.                move.l  intbase,a6        ;intuition base address
  731.                jsr     autorequest(a6)   ;display requester
  732.                rts
  733.  
  734.         The flags passed in D0 and D1 offer some interesting posibilites. 
  735.         The system messages that tells you to enter a particular disk are 
  736.         overlooked when the DISKINSERTED flag is similar.Putting a disk in
  737.         brings about the same responce as clicking the "Retry"button.
  738.         Whats new is the use of a text structure.Use three of them.Text   
  739.         structures are lists that contain entries for the text that you
  740.         need. 
  741.         These lists begin with two bytes that are used to define the
  742.         colour.The first byte is the colour of the text.The second is for
  743.         the background colour.Here this doesn't have any meaning.
  744.  
  745.         btext:
  746.                dc.b    2                 ;black text colour
  747.                dc.b    0                 ;background colour
  748.  
  749.         The next byte specifies the character mode.A zero means that the
  750.         text is output normally.A four means the text is output inverted.
  751.  
  752.                dc.b    0                 ;normal text representation
  753.  
  754.         The next entries are words.For this reason the addresses must be
  755.         even,so you need to either insert another byte or use the "align" 
  756.         pseudo-op.The following words are the X-and Y-position of the text
  757.         relative to the upper left corner of the requester.
  758.  
  759.                dc.w    10                ;X-position
  760.                dc.w    5                 ;Y-position relative to upper
  761.                                          ;left corner
  762.  
  763.         Next,theres a pointer to the character set that is used.Put a zero
  764.         here to use the standard set.
  765.  
  766.                dc.l    0                 ;standard character set
  767.  
  768.         Next you need to give the address of the text that should be
  769.         output.This text must be closed with a null byte.
  770.  
  771.                dc.l    text              ;pointer to text
  772.  
  773.         You need a long word at the end of the list that is either a
  774.         pointer to another text or a zero if no more text is needed.
  775.  
  776.                dc.l    0                 ;no more text
  777.  
  778.         Here are the three text structures that you need for the example:
  779.  
  780.         btext:                           ;text structure for the title
  781.                dc.b    0,1               ;colour
  782.                dc.b    0                 ;mode
  783.                align
  784.                dc.w    10,10             ;text position
  785.                dc.l    0                 ;standard font
  786.                dc.l    bodytxt           ;pointer to text
  787.                dc.l    0                 ;no more text
  788.  
  789.         bodytxt:
  790.                dc.b    "Requester Text",0
  791.                align
  792.         ltext:                           ;text structure of left button
  793.                dc.b    0,1               ;colour
  794.                dc.b    0                 ;mode
  795.                align 
  796.                dc.w    5,3               ;text position
  797.                dc.l    0                 ;standard font
  798.                dc.l    lefttext          ;pointer to text
  799.                dc.l    0                 ;no more text
  800.  
  801.         lefttext:
  802.                dc.b    "left",0
  803.                align
  804.  
  805.         rtext:
  806.                dc.b    0,1               ;colour
  807.                dc.b    0                 ;mode
  808.                align
  809.                dc.w    5,3               ;text position
  810.                dc.l    0                 ;standard font
  811.                dc.l    righttext         ;pointer to text
  812.                dc.l    0                 ;no more text
  813.  
  814.         righttext:
  815.                dc.b    "right",0
  816.                align
  817.  
  818.         After calling the requester,D0 contains the information about
  819.         which of the buttons were pressed,and in which button the event
  820.         took place.If D0 is zero,it was the right button.If it is one,it
  821.         was the left button.
  822.  
  823.       7.4.Event Handling.
  824.       -------------------
  825.         Pretend you've opened a window that as a close symbol,and you want
  826.         the program to react to this symbol being clicked.You need a
  827.         signal from Intuition that lets you know that an event as taken
  828.         place.The signal is called a message.
  829.         The IDCMP flag of the window specifies which events should cause
  830.         Intuition to send a message.By setting the bits for WINDOWCLOSE,  
  831.         you can allow a message to be sent when the close symbol is
  832.         clicked.
  833.         To get the message,you can use the EXEC function GetMsg (offset
  834.         -372).It needs the source address of the event as a parameter.Here
  835.         the source is the User port (which doesn't have anything to do
  836.         with the User port on old Commodore computors).
  837.         The User port contains a table which has entrieswhich specify the
  838.         events that have taken place and related things like mouse
  839.         position and time.
  840.         How do you find the User port?Use the pointer to the window
  841.         structure that you got back from the OpenWindow function and
  842.         stored in the "windowhd"memory block.
  843.         This pointer points to the window structure of this window.This
  844.         structure consists of a number of entries.Some are copies of the
  845.         parameters from our window definition table.We won't cover all the
  846.         entries,because most won't be interesting to you.You're more
  847.         interested in the pointer to the User port.Its in the window
  848.         structure.
  849.         You can find this in the long word that begins in the 86th byte of
  850.         the structure.You can get this long word with the following lines
  851.         of code:
  852.  
  853.                move.l  windowhd,a0       ;pointer to structure in A0
  854.                move.l  86(a0),a0         ;user port pointer in A0
  855.  
  856.         You can call the GetMsg function with this pointer in A0 by using 
  857.         the following lines of code in your program:
  858.  
  859.         GetMsg  = -372
  860.                ...
  861.                move.l  windowhd,a0       ;pointer to structure in A0
  862.                move.l  86(a0),a0         ;user port pointer in A0
  863.                move.l  execbase,a6       ;exec base address in A6
  864.                jsr     getmsg(a6)        ;get message
  865.  
  866.         This function returns a value in the D0 register.This value is a  
  867.         pointer to another structure,the Intuition Message Structure.If
  868.         theres a zero in D0,no event as taken place.
  869.         The long word that starts at the 20th byte in this structure
  870.         contains the information about which event took place.Evaluating
  871.         the information is easy,since the bits of this long word have the 
  872.         same meaning as the IDCMP flag that you described when you looked 
  873.         at opening windows.
  874.         Put the lines above after "loop"and then insert the following:
  875.  
  876.                move.l  d0,a0             ;message pointer in A0
  877.                move.l  20(a0),d6         ;save event in D6
  878.                tst.l   d0                ;did the event take place?
  879.                bne     end               ;yes!
  880.  
  881.         Now you can end this program by clicking the close symbol.This way
  882.         you can find out if an event as taken place.You can use D6 to
  883.         determine what event took place.In the example,D6 contains the
  884.         number $00000200,which means that the close symbol was clicked.
  885.         To see if this works with other events,change the $200 IDCMP flag
  886.         to $10200 in the window definition table.When you've assembled and
  887.         started this version,take the disk out of the drive-the program
  888.         terminates.
  889.         The IDCMP flags that you've got now cause the clicking of the
  890.         close symbol and the taking out of the disk (DISKREMOVED) to be
  891.         reported.If you want to find out which of the events took place,  
  892.         you can look in D6.It has a $200 in it if the window is closed,a  
  893.         $10000 if the disk was removed.
  894.  
  895.       7.5.Menu Programming.
  896.       ---------------------
  897.         Now lets look at one of Intuitions more interesting capabillities:
  898.         menu programming.By using menus,you can make your programs very
  899.         user friendly.
  900.         There are a lot of ways for you to use menus.You can make menu
  901.         points unusable,output sub-menus,choose the type of menu entries  
  902.         (allow text or pictures to be output),etc..To have lots of options
  903.         you need some parameters.
  904.         Lets produce a menu with the SetMenuStrip function (offset -264)
  905.         of Intuition.The function only needs two parameters,a pointer to
  906.         the menu structure of the window to be drawn and a pointer to the 
  907.         window structure of the window in which the menu is to function.  
  908.         Each window can have its own menu that is active when the window
  909.         is activated.
  910.         Heres the subroutine to set up the menu:
  911.  
  912.         SetMenuStrip =-264
  913.                ...
  914.         setmenu:                         ;* Initialize a menu
  915.                move.l  intbase,a6        ;intuition base address in A6
  916.                move.l  windowhd,a0       ;pointer to window structure
  917.                lea     menu,a1           ;pointer to menu structure
  918.                jsr     setmenustrip(a6)  ;call function
  919.                rts
  920.  
  921.         Heres a routine to erase the menu:
  922.  
  923.         ClearMenuStrip =-54
  924.                ...
  925.         clearmenu:
  926.                move.l  intbase,a6        ;intuition base address in A6
  927.                move.l  windowhd,a0       ;pointer to window structure
  928.                jsr     clearmenustrip(a6)
  929.                rts
  930.  
  931.         You've already got the pointer to the window structure.Lets look
  932.         at the menu structure you need for the menu.You need to build a
  933.         structure like this for each menu--for each menu title that
  934.         appears when you press the right mouse key.
  935.         This structure is a table with the following form:
  936.  
  937.         First there is a long word that points to the menu structure of
  938.         the next menu.If the current menu is the last one,a zero goes
  939.         here.
  940.  
  941.                align
  942.         menu:
  943.                dc.l    menu1             ;pointer to the next menu
  944.  
  945.         Next come two words which contain tha X- and Y-position of the
  946.         menu title:
  947.  
  948.                dc.w    20                ;X-position
  949.                dc.w    0                 ;Y-position
  950.  
  951.         Next,use two words to store the menu titles width and height in
  952.         pixels:
  953.  
  954.                dc.w    50                ;width
  955.                dc.w    10                ;height of menu title
  956.  
  957.         The next word contains the flag bit that determines whether the
  958.         menu is available or not.An unavailable menu either as grey
  959.         entries or they are drawn weakly.If the flag bit,bit 0,is set the 
  960.         menu is available.Otherwise,it is not.
  961.  
  962.                dc.w    1                 ;menu available
  963.  
  964.         Now comes a long word which functions as a pointer to the text
  965.         which is used as the menu title.Make sure the length isn't larger 
  966.         than the width entry allows!Otherwise unpleasent things will
  967.         happen.
  968.  
  969.                dc.l    menutext          ;pointer to title text
  970.  
  971.         Next comes a long word which functions as a pointer to the
  972.         structure of the first menu entry of this menu.Each menu entry
  973.         needs its own structure. 
  974.  
  975.                dc.l    menuitem01        ;pointer to the first menu item
  976.  
  977.         The last entries in the table are four words that are reserved for
  978.         internal functions.They must be here.
  979.  
  980.                dc.w    0,0,0,0           ;reserved words
  981.  
  982.         Thats the structure of the first menu.This structures first long
  983.         word points to the next structure which has the same form.The
  984.         pointer is set to zero in the last menu.
  985.         You still need the structure of the menu entries.These structure
  986.         tables have the following form:
  987.  
  988.         They start with a pointer to the next menu item.This pointer is
  989.         set to zero for the last entry.
  990.  
  991.                align
  992.         menuitem01:
  993.                dc.l    menuitem02        ;pointer to next menu item
  994.  
  995.         Next comes the four words:the X- and Y-position,the width and the 
  996.         height of the box the menu entry goes in.The size becomes obvious 
  997.         when the item is chosen by having the right mouse key clicked on
  998.         it.Then the box becomes visible.As you can see,the next word is   
  999.         determined in the flags.First lets set the position and size of
  1000.         the menu point,though:
  1001.  
  1002.                dc.w    0                 ;X-position of entry
  1003.                dc.w    0                 ;Y-position
  1004.                dc.w    90                ;width in pixels
  1005.                dc.w    10                ;height in pixels
  1006.  
  1007.         The position entries are relative to the upper left corner of the 
  1008.         menu that is pulled down.
  1009.         The following word was described above:it contains flags for
  1010.         entries to this menu item.There are several interesting variations
  1011.         possible.The following flag bits are contained in this word:
  1012.  
  1013.         Bit   Value   Name          Meaning When Set
  1014.         ------------------------------------------------------------------
  1015.          0    $0001   CHECKIT       Point is checked when chosen
  1016.          1    $0002   ITEMTEXT      Text menu item
  1017.          2    $0004   COMMSEQ       Choice can be made with keys as well
  1018.          3    $0008   MENUTOGGLE    Check turned on and off
  1019.          4    $0010   ITEMENABLED   Menu item available
  1020.          6    $0040   HIGHCOMP      Item inverted when chosen
  1021.          7    $0080   HIGHBOX       Iten framed when chosen
  1022.          8    $0100   CHECKED       Item is checked
  1023.  
  1024.         Heres a description of the bits:
  1025.  
  1026.         Name           Description
  1027.         ------------------------------------------------------------------
  1028.         CHECKIT        If this bit is set,a check or a user-defined
  1029.                        drawing is put in front of the text when the item  
  1030.                        is chosen.The text should begin with two blanks.
  1031.         
  1032.         ITEMTEXT       The menu item is a normal text if this bit is set. 
  1033.                        Otherwise a drawing is output.
  1034.  
  1035.         COMMSEQ        By setting this bit and entering a character,this  
  1036.                        menu point can be chosen by pressing the right
  1037.                        <Amiga> key and the key that was input.The input   
  1038.                        character is then displayed in the menu with the
  1039.                        Amiga symbol.There needs to be space available for 
  1040.                        this.
  1041.  
  1042.         MENUTOGGLE     If this bit is set and checking is allowed (bit 0),
  1043.                        the second time this point is chosen the check is
  1044.                        erased,the next time it is displayed again,etc...
  1045.  
  1046.         ITEMENABLED    Erasing this bit makes the menu item available.
  1047.  
  1048.         HIGHCOMP       If this bit is set,the box you've defined is
  1049.                        inverted when this menu item is chosen by the mouse
  1050.                        pointer.
  1051.  
  1052.         HIGHBOX        In this mode,the box is framed whin its chosen.
  1053.  
  1054.         The two previous bits determine the mode of the chosen menu item. 
  1055.         The following combinations are possible:
  1056.  
  1057.         HIGHIMAGE      If both bits are cleared,choosing the bit causes a 
  1058.                        self-defined drawing to be output.
  1059.  
  1060.         HIGHNONE       When both bits are set,there isn't any reaction to 
  1061.                        choosing this item.
  1062.  
  1063.         CHECKED        This bit can be set by either the program or
  1064.                        Intuition.It lets you know if the menu text has a
  1065.                        check next to it or not.You can use this to find
  1066.                        out if the item was checked by testing but eight.If
  1067.                        its set,the item was checked.You can also use it to
  1068.                        cause the item to be checked.
  1069.  
  1070.         You're choosing the mode CHECKIT,ITEMTEXT,COMMSEQ,MENUTOGGLE,ITEM-
  1071.         ENABLED and HIGHBOX for the example:
  1072.  
  1073.               dc.w    $10011111         ;mode flag
  1074.  
  1075.         Lets get back to the structure of the menu items.After the flag
  1076.         word,there is a long word whose flag bits determine whether this  
  1077.         menu point can be turn off another one.Set this to zero:
  1078.  
  1079.               dc.l    0                 ;no connection
  1080.  
  1081.         Now comes the pointer to the structure of the text that should be 
  1082.         displayed.If the ITEMTEXT bit isn't set,this pointer must point to
  1083.         the structure of the drawing.If nothing should be shown,you can
  1084.         set this to zero.Use a text in the example and write the
  1085.         following:
  1086.  
  1087.               dc.l    menu01text        ;pointer to menu text structure
  1088.  
  1089.         The following long word only has a meaning if the HIGHIMAGE flag
  1090.         is set.Then this long word points to the text or the drawing that 
  1091.         should be displayed when the menu items box is clicked.Otherwise  
  1092.         the long word is ignored,so insert a zero:
  1093.  
  1094.               dc.l    0                 ;no drawing when clicked
  1095.  
  1096.         The next entry is a byte that is used for input of keyboard
  1097.         characters,which together with the right <Amiga> key can be used
  1098.         to choose the menu item.This only works if the COMMSEQ bit is set.
  1099.         Place a character here:
  1100.  
  1101.               dc.b    'A'               ;choose item using <Amiga>/'A'
  1102.  
  1103.         Since the next item is a long word,you need an "align"peudo-op
  1104.         here.Next comes the long word that points to the menu item
  1105.         structure or a submenu.The submenu is automatically shown when
  1106.         this menu item is clicked.You can't nest them any deeper,however, 
  1107.         so this long word is ignored for submenus.
  1108.         If you don't want a submenu to this item,put a zero here:
  1109.  
  1110.           align
  1111.               dc.l    0                 ;no submenu
  1112.  
  1113.         The next and final long word is written to by Intuition if you
  1114.         choose several menu itens.In this case,the menu number of the next
  1115.         menu item chosen goes here:
  1116.  
  1117.               dc.l    0                 ;preparation
  1118.  
  1119.         Thats the structure for a menu item.You still need the text
  1120.         structure for the text of the item.This isn't complicated,but it
  1121.         makes you get into fine details about the form of the menu.You've 
  1122.         already learned about this text structure when you looked at
  1123.         requesters,so we'll skip an explanation.
  1124.         Heres the complete structure of an example menu.You can use two
  1125.         menus,each with two subpoints.The second menu point of the left
  1126.         menu has a submenu with two entries.You ought to type this program
  1127.         in,so that you can experiment with it.You can also use this
  1128.         example to evaluate the clicked menu item.
  1129.  
  1130.         ;**Complete menu structure foe example menu **
  1131.         menu:
  1132.                dc.l menu1         ;no next menu
  1133.                dc.w 10,30         ;X/Y
  1134.                dc.w 50,10         ;width/height
  1135.                dc.w 1             ;menu enabled
  1136.                dc.l menuname      ;menu title
  1137.                dc.l menuitem01    ;menu entry
  1138.         menuname:
  1139.                dc.b "Menu 1",0    ;first menu name
  1140.            align
  1141.         menu1:
  1142.                dc.l 0             ;no further menu
  1143.                dc.w 80,0          ;see above
  1144.                dc.w 50,10
  1145.                dc.w 1
  1146.                dc.l menuname1
  1147.                dc.l menuitem11
  1148.                dc.w 0,0,0,0
  1149.         menuname1:
  1150.                dc.b "Menu 2",0    ;second menu name
  1151.            align
  1152.         menuitem01:               ;first menu item
  1153.                dc.l menuitem02    ;pointer to next entry
  1154.                dc.w 0,0           ;X/Y
  1155.                dc.w 130,12        ;width/height
  1156.                dc.w $9f           ;flags
  1157.                dc.l 0             ;exclude
  1158.                dc.l text01        ;pointer to text structure
  1159.                dc.l 0             ;select fill
  1160.                dc.b "1"           ;command
  1161.            align
  1162.                dc.l 0             ;subitem:none
  1163.                dc.w 0             ;next select:no
  1164.         text01:
  1165.                dc.b 0,1           ;colours
  1166.                dc.b 0             ;mode:overwrite
  1167.            align
  1168.                dc.w 5,3           ;X/Y position
  1169.                dc.l 0             ;standard character set
  1170.                dc.l text01txt     ;pointer to text
  1171.                dc.l 0             ;no more text
  1172.         text01txt:
  1173.                dc.b "Point 0.1",0
  1174.            align
  1175.         menuitem02:               ;second menu item
  1176.                dc.l 0
  1177.                dc.w 0,10
  1178.                dc.w 130,12
  1179.                dc.w $57
  1180.                dc.l 0
  1181.                dc.l text02
  1182.                dc.l 0
  1183.                dc.b "2"           ;activate with <Amiga>/'2'
  1184.            align
  1185.                dc.l 0
  1186.                dc.w 0
  1187.         text02:
  1188.                dc.b 0,1
  1189.                dc.b 0
  1190.            align
  1191.                dc.w 5,3
  1192.                dc.l 0
  1193.                dc.l text02txt
  1194.                dc.l 0
  1195.         text02txt:
  1196.                dc.b "Point 0.2",0
  1197.            align
  1198.         menuitem11:               ;first menu point of the second menu
  1199.                dc.l menuitem12    ;pointer to second menu point
  1200.                dc.w 0,0
  1201.                dc.w 90,12
  1202.                dc.w $52
  1203.                dc.l 0 
  1204.                dc.l text11
  1205.                dc.l 0
  1206.                dc.b 0
  1207.            align
  1208.                dc.l 0
  1209.                dc.w 0
  1210.         text11:
  1211.                dc.b 0,1
  1212.                dc.b 0
  1213.            align
  1214.                dc.w 5,3
  1215.                dc.l 0
  1216.                dc.l text11txt
  1217.                dc.l 0
  1218.         text11txt:
  1219.                dc.b "Point 1.1",0
  1220.            align
  1221.         menuitem12:               ;second menu item of second menu
  1222.                dc.l 0             ;no more items
  1223.                dc.w 0,10
  1224.                dc.w 90,12
  1225.                dc.w $92
  1226.                dc.l 0
  1227.                dc.l text12
  1228.                dc.l 0
  1229.                dc.b 0
  1230.            align
  1231.                dc.l submenu0      ;pointer to submenu
  1232.                dc.w 0
  1233.         text12:
  1234.                dc.b 0,1
  1235.                dc.b 0
  1236.            align
  1237.                dc.w 5,3
  1238.                dc.l 0
  1239.                dc.l text12txt
  1240.                dc.l 0
  1241.         text12txt:
  1242.                dc.b "Point 1.2",0
  1243.            align
  1244.         submenu0:                 ;first point of submenu
  1245.                dc.l submenu1      ;pointer to next point
  1246.                dc.w 80,5
  1247.                dc.w 90,12
  1248.                dc.w $52
  1249.                dc.l 0
  1250.                dc.l texts0
  1251.                dc.l 0
  1252.                dc.b 0
  1253.            align
  1254.                dc.l 0
  1255.                dc.w 0
  1256.         texts0:
  1257.                dc.b 0,1
  1258.                dc.b 0
  1259.            align
  1260.                dc.w 5,3
  1261.                dc.l 0,texts0txt,0
  1262.         texts0txt:
  1263.                dc.b "S Point 1",0
  1264.            align
  1265.         submenu1:                 ;submenu,second item
  1266.                dc.l 0
  1267.                dc.w 80,15
  1268.                dc.w 90,12
  1269.                dc.w $52
  1270.                dc.l 0
  1271.                dc.l texts1
  1272.                dc.l 0
  1273.                dc.b 0
  1274.            align
  1275.                dc.l 0
  1276.                dc.w 0
  1277.         texts1:
  1278.                dc.b 0,1
  1279.                dc.b 0
  1280.            align
  1281.                dc.w 5,3
  1282.                dc.l 0
  1283.                dc.l texts1txt
  1284.                dc.l 0
  1285.         texts1txt:
  1286.                dc.b "S Point 2",0
  1287.            align
  1288.  
  1289.         The menu items in this example have the following properties as a 
  1290.         result of their flags:
  1291.  
  1292.       Menu 1;
  1293.         The first item,"Point 0.1",can be chosen using the right <Amiga>
  1294.         key and the "1" key.This point alternates between checked and not 
  1295.         checked,which can easily be used to check out the key function.If
  1296.         the item is checked and you hit both keys,the check disappears and
  1297.         vice versa.The box at this point is framed when the mouse pointer 
  1298.         clicks on it.
  1299.         The second item,"Point 0.2",can be chosen using the right <Amiga> 
  1300.         key and the "2"key.This item is checked the first time it is
  1301.         chosen.However,in contrast to the item above,it can't be erased.  
  1302.         The box of this item is inverted when clicked.
  1303.  
  1304.       Menu 2;
  1305.         These two points can't be chosen using keys.The box of the upper  
  1306.         item is inverted when clicked on:the lower one is framed.When you 
  1307.         click the second item,"Point 1.2",a submenu with two entries is
  1308.         displayed.
  1309.  
  1310.         Experiment with this structure a little bit.Change some values and
  1311.         see what happens.As you can see,menu programming isn't as bad as
  1312.         you thought,and it offers a lot of options (but you'll have to do
  1313.         lots of typing!).
  1314.         When you've done experimenting,you'll want to produce your own
  1315.         program with menus.How does the program find whether a menu item
  1316.         in a menu has been clicked on?
  1317.         You already looked at one way to find out the menus state.You can
  1318.         test the CHECKED bit in the flag word of a menu item.If this is
  1319.         set,the user clicked on this item with the mouse.
  1320.         This only works if checking is allowed for the item being tested. 
  1321.         You could allow all the menu items to be checked,but this still
  1322.         isn't a good solution--it requires testing all the flag bits of
  1323.         all the menus one after the other.That makes very boring
  1324.         programming.
  1325.         You've already learned about finding about events from Intuition. 
  1326.         You've moved the message about which event took place into D6,and 
  1327.         you can look at it to find out what happend.
  1328.         If you set the eight bit,the MENUPICK bit,of the IDCMP flag long
  1329.         word in the window definition,the choice of the menu point is
  1330.         reported.Put the following lines in your loop in the main program.
  1331.  
  1332.         loop:
  1333.                move.l  execbase,a6      ;exec base address in A6
  1334.                move.l  windowhd,a0      ;window structure pointer
  1335.                move.l  86(a0),a0        ;user point pointer in A0
  1336.                jsr     getmsg(a6)       ;get message
  1337.                tst,l   d0               ;whay happend?
  1338.                beq     loop             ;nothing happend
  1339.                move.l  d0,a0            ;message pointer in A0
  1340.                move.l  $14(a0),d6       ;event in D6
  1341.  
  1342.         If the program makes it out of the loop,an event as taken place.  
  1343.         You have the events flag in the D6 register.You can evaluate the  
  1344.         event using CMP or BTST to find out which flag bits are set.You
  1345.         can then execute the function corresponding to the set bit.You can
  1346.         use lines like the following ones:
  1347.  
  1348.                cmp     #$200,d6         ;WINDOWCLOSE?
  1349.                beq     ende             ;yes:program end
  1350.  
  1351.         These lines terminate the program when the window is closed.
  1352.  
  1353.         If the user chose a menu item,there is a $100 in the D6 register.
  1354.         You now need to determine which item it was.
  1355.         You can find this information in a word that comes right after the
  1356.         long word with the event flags in the message structure.Write:
  1357.  
  1358.                move    $18(a0),d7
  1359.  
  1360.         You now have the code for the clicked menu item in the D7
  1361.         register.If the user just pressed the right key and let it go
  1362.         without choosing a menu item,you'll find a $FFFF here.This word
  1363.         doesn't contain just one,but three pieces of information:
  1364.  
  1365.           Which menu was the item chosen from?
  1366.           Which menu item?
  1367.           Which submenu?
  1368.  
  1369.         The information is divided in three bit groups.The division is as 
  1370.         follows:
  1371.  
  1372.         Bits  0-4   Menu title number
  1373.         Bits  5-10  Menu item number
  1374.         Bits 11-15  Submenu item number
  1375.  
  1376.         The numbering begins with zero-ie the first menu point of the
  1377.         first menu has the numbers 0 and 0.
  1378.         
  1379.         To try this out insert the following lines:
  1380.  
  1381.                move    d7,d6            ;move code into D6
  1382.                lsr     #8,d7            ;shift right 11 times
  1383.                lsr     #3,d7            ;submenu item now in D7
  1384.                clr.l   d5
  1385.                roxr    #1,d6            ;bit 0 in X-flag
  1386.                roxl    #1,d5            ;menu number now in D5
  1387.                and.l   #$7f,d6          ;issolate lower bits
  1388.                cmp     #$7f,d6          ;no menu item?
  1389.                beq     loop             ;no:continue
  1390.                lsr     #4,d6            ;else menu item in D6
  1391.                ende
  1392.  
  1393.         By making a test run with AssemPro,you can easily see if this
  1394.         works right-just look at the registers after the program is over.
  1395.  
  1396.         If you,for example,want to write a program with four menus with 10
  1397.         menu items each,this sort of method is too much work-there are 44 
  1398.         tables.For this reason,lets look at a short program that takes
  1399.         care of the necessary structure table itself.
  1400.         The menu structure is built very simply-it doesn't offer submenus 
  1401.         or the option of choosing items via the keyboard.If you want these
  1402.         extras,you can still use this program,but you'll have to use MOVE 
  1403.         commands to insert the desired flags and pointers.
  1404.         The input that this program needs is a list of the menu names and 
  1405.         the items in each menu.The addresses of the menu texts go in a
  1406.         table with the following simple form:
  1407.  
  1408.               dc.l   Menu title 1
  1409.               dc.l   Point1,Point2,Point3,...,0
  1410.               dc.l   Menu title 2
  1411.               dc.l   Point1,Point2,Point3,...,0
  1412.               dc.l   Menu title 3 oder 0
  1413.  
  1414.         This program is set up in such a way that up to four menus can lie
  1415.         next to each other (in normal screen resolution),which is often
  1416.         plenty.The table above ends by putting a zero instead of a pointer
  1417.         to the nxt menu title.As you can see,its pretty simple.
  1418.         This program is inserted in your big program right behind the
  1419.         "setmenu"label.After the "bsr setmenu"command is executed,the menu
  1420.         structure is built and initialized at the same time.You don't need
  1421.         to change the rest of the program,it'll be shorter that way.
  1422.  
  1423.         Heres the program fragment for the complete "setmenu"routine:
  1424.  
  1425.         setmenu:                        ;*initialize menu structure
  1426.                lea     mentab,a0        ;pointer to text pointer in A0
  1427.                lea     menu,a1          ;pointer to menu field in A1
  1428.                move    #10,d1           ;horizontal menu position=10
  1429.  
  1430.         menuloop:
  1431.                clr.l   d2               ;vertical menu position=0
  1432.                move.l  a1,a2            ;save address of pointer
  1433.                tst.l   (a0)             ;another menu there?
  1434.                beq     setmenu1         ;no:quit
  1435.                clr.l   (a1)+            ;"no more menus"preperations
  1436.                move    d1,(a1)+         ;set X-position
  1437.                add.l   #70,d1           ;and increment
  1438.                move.l  #50,(a1)+        ;Y-position and width
  1439.                move.l  #$a0001,(a1)+    ;height and flag
  1440.                move.l  (a0)+,(a1)+      ;menu title
  1441.                lea     12(a1),a3
  1442.                move.l  a3,(a1)+         ;pointer to menu item
  1443.                clr.l   (a1)+            ;reserved words
  1444.                clr.l   (a1)+
  1445.  
  1446.         itemloop:
  1447.                tst.l   (a0)             ;last entry?
  1448.                beq     menuend          ;yes:menu done
  1449.                lea     54(a1),a3
  1450.                move.l  a3,(a1)+         ;pointer to next item
  1451.                move.l  d2,(a1)+         ;X- and Y-positions
  1452.                add     #10,d2           ;Y-position+10
  1453.                move.l  #$5a000a,(A1)+   ;WIDTH/HEIGHT
  1454.                move    #$52,(a1)+       ;flag:normal
  1455.                clr.l   (a1)+            ;no connection
  1456.                lea     16(a1),a3
  1457.                move.l  a3,(a1)+         ;text structure pointer
  1458.                clr.l   (a1)+            ;no fill structure
  1459.                clr.l   (a1)+            ;no command,no submenu
  1460.                clr.l   (a1)+            ;and no continuation
  1461.                move    #$1,(a1)+        ;set text structure:colour
  1462.                clr.l   (a1)+            ;mode 0
  1463.                move.l  #$50003,(a1)+    ;X- and Y-position
  1464.                clr.l   (a1)+            ;standard character set
  1465.                move.l  (a0)+,(a1)+      ;text pointer
  1466.                clr.l   (a1)+            ;no continuation
  1467.                bra     itemloop         ;next item...
  1468.  
  1469.         menuend:                        ;eventual transfer to next menu
  1470.                clr.l   -54(a1)          ;erase pointer to next item
  1471.                tst.l   (a0)+            ;increment table pointer
  1472.                tst.l   (a0)             ;another menu there?
  1473.                beq     setmenu1         ;no:done
  1474.                move.l  a1,(a2)          ;pointer to next menu
  1475.                bra     menuloop         ;and continue
  1476.         setmenu1:                       ;*initialize menu (like before)
  1477.                move.l  intbase,a6       ;intuition base address in A6
  1478.                move,l  windowhd,a0      ;window structure in A0
  1479.                lea     menu,a1          ;pointer to menu structure
  1480.                jsr     setmenustrip(a6)
  1481.                rts
  1482.  
  1483.         You need three things yet for this program:the memory to be used
  1484.         for the structure,the table of text pointers and the text.Heres an
  1485.         example:
  1486.  
  1487.         mentab:
  1488.                dc.l menu1               ;first menu title
  1489.                dc.l mp11,mp12,mp13      ;menu items
  1490.                dc.l 0                   ;end of menu 1
  1491.                dc.l menu2               ;second menu title
  1492.                dc.l mp21,mp22,mp23      ;menu items
  1493.                dc.l 0                   ;end of menu 2
  1494.                dc,l 0                   ;you're out of menus!
  1495.  
  1496.         ;** Menu Text **
  1497.         menu1: dc.b "Menu 1",0
  1498.         mp11:  dc.b "Point11",0
  1499.         mp12:  dc.b "Point12",0
  1500.         mp13:  dc.b "Point13",0
  1501.         menu2: dc.b "Menu 2",0
  1502.         mp21:  dc.b "Point21",0
  1503.         mp22:  dc.b "Point22",0
  1504.         mp23:  dc.b "Point23",0
  1505.             align
  1506.         ;** Storage space for menu structure **
  1507.         menu:  blk.w 500
  1508.  
  1509.         Make sure that the memory area reserved for the menu structure is 
  1510.         big enough and change the entry "blk.w 500"to the calculated
  1511.         value. 
  1512.         If you use this program,and want to build some special features
  1513.         into the menu (for instance key commands),you can make entries in
  1514.         the menu structure table while the program is running.You can find
  1515.         the word (or byte or long word) that interests you in the table as
  1516.         follows:
  1517.  
  1518.         For example,to find the keyboard command byte of the second entry
  1519.         in the first menu,calculate as follows:
  1520.  
  1521.         Address = Start_address+Menu*30+(entry-1)*54+26
  1522.  
  1523.         which in the example comes to:
  1524.  
  1525.         Address = menu+30+54+26
  1526.                 = menu+110
  1527.  
  1528.         The 26 is the distance from the beginning of the MenuItem
  1529.         structure to the desired byte,the command byte.In this way,you can
  1530.         calculate the addresses and use MOVE commands to modify the menu
  1531.         to fit your wishes.By the way,in the example above,the correspond-
  1532.         ing flag bit must be set as well,so that the keyboard command is  
  1533.         recognized.
  1534.         Now lets get back to the window.Its nice to have a window that you
  1535.         can change and close,but you really want to be able to output text
  1536.         in a window!
  1537.  
  1538.       7.6.Text Output.
  1539.       ----------------
  1540.         Its very easy to use Intuition's text output function.Use the
  1541.         PrintIText function (offset -216).It needs four parameters.
  1542.  
  1543.         In A0    A pointer to the RastPort of the window.You can find this
  1544.                  in the window structure.
  1545.         In A1    A pointer to the text structure of the text that should
  1546.                  be output.
  1547.         In D0    The X-position.
  1548.         In D1    The Y-position of the text in the window.
  1549.  
  1550.         Its very easy to enter the X- and Y-positions.You've already used 
  1551.         the text structure twice (for requesters and menus).
  1552.         Whats new is accessing the windows RastPort.The RastPort is a
  1553.         structure that describes the window.The address is needed by
  1554.         several Intuition functions.
  1555.         The pointer to the RastPort starts at the 50th byte in the window 
  1556.         structure.You can access it as follows:
  1557.  
  1558.             move.l  windowhd,a0           ;address of window structure
  1559.             move.l  50(a0),a0             ;RastPort address in A0
  1560.  
  1561.         Now you've got the address of the RastPort.Lets write a routine
  1562.         that prints a text.The X- and Y-positions are in D0 and D1
  1563.         respectively and the address of the text structure in A1 before
  1564.         the routine is called:
  1565.  
  1566.         PrintIText = -216
  1567.                ...
  1568.         print:
  1569.                move.l  intbase,a6       ;intuition base address in A6
  1570.                move.l  windowhd,a0      ;address of window structure
  1571.                move.l  50(a0),a0        ;rastport address in A0
  1572.                jsr     printitext(a6)   ;call function
  1573.                rts
  1574.  
  1575.         You can try out this routine by using the requesters text that is 
  1576.         still in a structure of the program.Write the following lines
  1577.         before the "loop"label:
  1578.  
  1579.                lea     btext,a1         ;pointer to text structure in A1
  1580.                move.l  #10,d0           ;X-position
  1581.                move.l  #30,d1           ;Y-position of text
  1582.                bsr     print            ;output text
  1583.  
  1584.         Start the program and the text appears in the middle of the window
  1585.         If this doesn't happen,check the colour of the text in the text   
  1586.         structure.Its probably zero.Just change it to three,and the text  
  1587.         appears in red the next time you start the program.
  1588.  
  1589.       7.7.Images.
  1590.       -----------
  1591.         An image is a drawing that goes in a rectangular field and is
  1592.         defined bitwise.The disk symbol of the Intuition screen and the   
  1593.         system gadgets in the screen and window borders are examples of
  1594.         such Images.
  1595.         The rectangle that the drawing goes in can be arbitrarily large,  
  1596.         but each pixel in the rectangle needs its own bit,so programming  
  1597.         screen-sized Images isn't advisable.You'll stick to an Image that 
  1598.         requires about 32x16 bits-an Image thats about 3x1cm.
  1599.         You can make all sorts of images as you've seen looking at window 
  1600.         gadgets.There is an Intuition functionthat draws an Image:It is
  1601.         the DrawImage function (offset -114) and it needs 4 parameters:
  1602.  
  1603.         In A0   The address of the rastport image is drawn in.You've
  1604.                 already learned how to access this address in the section 
  1605.                 on the text function.
  1606.         In A1   The structure address of the image to be drawn.
  1607.         In D0   The relative X-position
  1608.         In D1   The relative Y-position of the drawing.
  1609.  
  1610.         Lets draw this picture in your window.It justs takes a simple
  1611.         routine.You just need to put the address of the image structure in
  1612.         A1 and the position of the image in D0 and D1 before you call it.
  1613.  
  1614.         DrawImage =-114
  1615.                ...
  1616.         draw:                           ;*draw image
  1617.                move.l  intbase,a6       ;intuition base address in A6
  1618.                move.l  windowhd,a0      ;pointer to window structure
  1619.                move.l  50(a0),a0        ;now,rastport address in A0
  1620.                jsr     drawimage(a6)    ;draw image
  1621.                rts
  1622.  
  1623.         Now you need the structure of the image.The structure contains
  1624.         nine entries which have the following meanings:
  1625.  
  1626.         The first two entries are words which specify the distance in the 
  1627.         X- and Y-direction from the co-ordinates that were given to tell  
  1628.         where the image should be drawn.You'll just put two zeros here:
  1629.  
  1630.         image:
  1631.                dc.w  0,0                ;X- and Y-position
  1632.  
  1633.         Next come two words which specify the width and height of the
  1634.         image in pixels.Lets draw a 32x13 point image.Enter: 
  1635.  
  1636.                dc.w  32,13              ;width and height of image
  1637.  
  1638.         The next word in the list specifies the number of planes in the
  1639.         drawing.If its a simple image that only uses two colours,just
  1640.         enter a one.For more colours,you'll need a correspondingly bigger 
  1641.         number.When more colurs are worked with,the bit pattern of the
  1642.         image must have more data.Lets just have one bit plane:
  1643.  
  1644.                dc.w  1                  ;one bitplane:2^1=2 colours
  1645.  
  1646.         Next comes a long word that points to the data of the image:
  1647.  
  1648.                dc.l  imgdata            ;pointer to image data
  1649.  
  1650.         The next two bytes are very interesting.The first byte,the
  1651.         PlanePick byte,tells which plane of the window or screen the image
  1652.         data should be written in.Since you only have one plane,you need
  1653.         to enter the bit plane of the window.This information is found in
  1654.         the bits of the byte-bit0 stands for plane 0,bit 1 for plane 1,etc
  1655.         ..You also define the colour of the image with this input.If you
  1656.         enter a two,every set bit of your image represents a red point.
  1657.  
  1658.                dc.b  2                  ;drawing red:plane 1
  1659.  
  1660.         The second byte,the PlaneOnOff byte,is an interesting enhancement.
  1661.         Each bit of the window bit plane corresponds to a whole number
  1662.         here.The only bytes that are interesting though are the ones that
  1663.         are cleared in the PlanePick byte.If the bit is set in PlaneOnOff,
  1664.         evert bit of the image in the corresponding plane is set.Otherwise
  1665.         they are cleared.To make sure that each bit of the image that
  1666.         isn't set appears white,enter a one.All the bits of the image that
  1667.         aren't set,are set in Plane 1 and appear white.
  1668.  
  1669.                dc.b  1                  ;background:white
  1670.  
  1671.         The last entry of the structure is a lobg word that points to
  1672.         another image.You don't need this,so set the long word to zero:
  1673.  
  1674.                dc.l  0                  ;no more images
  1675.  
  1676.         Heres a quick overview of the image structure:
  1677.        
  1678.         image:
  1679.                dc.w  0,0                ;X- and Y-positions
  1680.                dc.w  32,13              ;width and height of image
  1681.                dc.w  1                  ;one bitplane:2^1=2 colours
  1682.                dc.l  imgdata            ;pointer to image data
  1683.                dc.b  2                  ;drawing red:plane 1
  1684.                dc.b  1                  ;background:white
  1685.                dc.l  0                  ;no more images
  1686.  
  1687.         Now lets produce the image data.Each image row uses a word,long
  1688.         word,or several of these represent the pattern.The set points of
  1689.         the image correspond to the set bits.This is repeated as often as 
  1690.         the height of the image requires.The data on each line must begin 
  1691.         on a word border,on a even address.
  1692.         For the example,its easy to decide on the data,since you're going 
  1693.         32 points across-that corresponds to exacty one long word.Its
  1694.         easiest to program the image using the binary representation of
  1695.         the data.
  1696.         Lets use,as an example,an image that represents a switch in "OFF" 
  1697.         mode.This form is chosen for a good reason,so you should type it
  1698.         in.In the chapter on gadgets thats coming up,we'll show you how to
  1699.         turn the switch on.Here is the example data for the switch image:
  1700.  
  1701.         imgdata:   ;Data for switch in "OFF" mode
  1702.            dc.l    %00000000000000000000000000000000
  1703.            dc.l    %00000000000000000000111000000000
  1704.            dc.l    %00011101110111000001111100000000
  1705.            dc.l    %00010101000100000001111100000000
  1706.            dc.l    %00010101100110000001111000000000
  1707.            dc.l    %00011101000100000011100000000000
  1708.            dc.l    %00000000000000000111000000000000
  1709.            dc.l    %00000000000000001110000000000000
  1710.            dc.l    %00000000000111111111100000000000
  1711.            dc.l    %00000000001111111111110000000000
  1712.            dc.l    %00000000001111111111110000000000
  1713.            dc.l    %00000000000110000001100000000000
  1714.            dc.l    %00000000000000000000000000000000
  1715.  
  1716.         Once you've typed in this data,you can experiment with displaying
  1717.         it on the screen.Enter the following lines before the "loop"label:
  1718.  
  1719.             move.l  image,a1           ;pointer to image structure
  1720.             move    #30,d0             ;X-postion in window
  1721.             move    #50,d1             ;Y-position
  1722.             bsr     draw               ;draw image
  1723.  
  1724.         How do you like the image on the screen?You'll run into this
  1725.         switch again when we talk about putting the switch in the "ON"    
  1726.         state when discussing gadgets.You need to look at other methods of
  1727.         drawing in the window first,though.
  1728.  
  1729.       7.8.Borders.
  1730.       ------------
  1731.         A border is a collection of lines that are connected.They can be
  1732.         of any length or at any angle.Intuition lets you draw borders to
  1733.         do things like put frames around windows and screens.They are used
  1734.         to put borders around pictures or text,especially for use with
  1735.         string gadgets.We'll talk about that later,though.
  1736.         Its easy to draw borders.Just use the Intuition function
  1737.         DrawBorder (offset -108) which needs four parameters:
  1738.  
  1739.         In A0   The rastport address of the output medium the lines should
  1740.                 be drawn in.Use your window.
  1741.         In A1   The address of the border structure.We'll look at the form
  1742.                 of this structure shortly.
  1743.         In D0   The relative X-co-ordinate which is used with the X- and Y
  1744.                 co-ordinate list to calulate the actual line co-ordinates.
  1745.         In D1   The relative Y-co-ordinates.Relative,here too,means that
  1746.                 this is relative to the upper left corner of the screen.
  1747.  
  1748.         Lets write a short routine that is called with three parameters.  
  1749.         The structure address in A1 and the X and Y co-ordinates are in D0
  1750.         and D1 respectively when the routine is called.The border is drawn
  1751.         in the window whose structure address is in "windowhd".
  1752.  
  1753.         DrawBorder =-108
  1754.                ...
  1755.         borderdraw:                     ;* draw several lines
  1756.                move.l  inbase,a6        ;intuition base address in A6
  1757.                move.l  windowhd,a0      ;pointer to window structure
  1758.                move.l  50(a0),a0        ;now rastport address in A0
  1759.                jsr     drawborder(a6)   ;draw lines
  1760.                rts
  1761.  
  1762.         Now lets look at the border structure.The list needs the eight
  1763.         following parameters:
  1764.  
  1765.         First,you need two words for the vertical and horizontal distance 
  1766.         from the co-ordinates given in the function call.To avoid losing  
  1767.         sight of some of the many distance entries,put two zeros here:
  1768.  
  1769.         border:
  1770.                dc.w  0                  ;horizontal distance
  1771.                dc.w  0                  ;vertical distance
  1772.  
  1773.         Next come two bytes that determine the colour.Use a red frame:
  1774.  
  1775.                dc.b  3                  ;red frame
  1776.                dc.b  0                  ;background (unused)
  1777.  
  1778.         As you can see,the background colour isn't used.You have two modes
  1779.         to choose between for drawing the lines.The following mode
  1780.         determines the mode that is used.If it is zero,each line is drawn
  1781.         in the colour chosen,no matter what was done before.This is the
  1782.         JAM1 mode.The other mode is the XOR mode which ignores both colour
  1783.         entries.In this mode,all the points that lie under the line have
  1784.         their colour value inverted.As a result,a white point becomes
  1785.         black,and a blue one becomes red.That is mode two.Lets use the
  1786.         JAM1 mode for the example:
  1787.  
  1788.                dc.b  0                  ;mode:JAM1 (2=XOR)
  1789.  
  1790.         The next entry specifies how many co-ordinate pairs there are in
  1791.         the list.Since this word must be on an even address,you need to
  1792.         use the "align"peudo-op first.Then enter the number of pairs.     
  1793.         Remember that you need three points to draw two lines:beginning,  
  1794.         corner and end point.To draw a rectangular frame,you need five
  1795.         pairs:
  1796.  
  1797.                dc.b  5                  ;5 X,Y pairs used together
  1798.  
  1799.         The next item is a pointer to the co-ordinate table that contains
  1800.         a list of points to be connected:
  1801.  
  1802.                dc.l  coord              ;pointer to cordinate table
  1803.  
  1804.         The border structures final entry is a long word that can point to
  1805.         another border structure.If you don't have any more structures to
  1806.         be pointed to,just enter a zero here.The pointer is useful for
  1807.         connecting two independant border structures-for example,to
  1808.         produce a two coloured frame that really stands out.You don't need
  1809.         this pointer in the example,though:
  1810.  
  1811.                dc.l  0                  ;no more structures
  1812.  
  1813.         Thats the border structure.Now lets look at the co-ordinate list.
  1814.         For the example,it consists of five pairs of numbers which
  1815.         represent a rectangle.I recommend entering these values,because
  1816.         you'll use them in example programs further down the line.
  1817.  
  1818.         coord:                          ;coordinates for rectangle frame
  1819.                dc.w  -2,-2
  1820.                dc.w  80,-2
  1821.                dc.w  80,9
  1822.                dc.w  -2,9
  1823.                dc.w  -2,-2
  1824.  
  1825.         Heres a quick overview of the border structure:
  1826.  
  1827.         border:
  1828.                dc.w  0                  ;horizontal distance
  1829.                dc.w  0                  ;vertical distance
  1830.                dc.b  3                  ;red frame
  1831.                dc.b  0                  ;background (unused)
  1832.                dc.b  0                  ;mode:JAM1 (2=XOR)
  1833.                dc.b  5                  ;5 X,Y pairs used together
  1834.                dc.l  coord              ;pointer to cordinate table
  1835.                dc.l  0                  ;no more structures
  1836.         coord:                          ;coordinates for rectangle frame
  1837.                dc.w  -2,-2
  1838.                dc.w  80,-2
  1839.                dc.w  80,9
  1840.                dc.w  -2,9
  1841.                dc.w  -2,-2
  1842.  
  1843.         Once you've typed this in,you can try the whole thing out.Type the
  1844.         following lines before the "loop"label in the program:
  1845.  
  1846.                lea     border,a1        ;address of the border structure
  1847.                move    #20,d0           ;X base position
  1848.                move    #80,d1           ;Y base position
  1849.                bsr     drawborder       ;draw frame
  1850.  
  1851.         As you can see,using enough X and Y co-ordinates,you can draw the 
  1852.         Eiffel tower.Thats enough about simple drawings.You want to put
  1853.         some life into your drawings and text.Lets manipulate them with
  1854.         the mouse!
  1855.  
  1856.       7.9.Gadgets.
  1857.       ------------
  1858.         We already talked a bit about gadgets when you looked at screen
  1859.         construction.Looking at system gadgets like the window close
  1860.         symbol,you can activate by clicking and causes a program function 
  1861.         to be executed.
  1862.         You can make your own gadgets as well.Intuition allows you a lot
  1863.         of interesting possibilities.
  1864.         
  1865.         There are four types of gadgets:
  1866.  
  1867.         Boolean gadgets are used in Yes/No situations.You can click and
  1868.         activate it (Yes) or deactivate it (No).
  1869.  
  1870.         String gadgets are used to accept input of text of a specified
  1871.         length.
  1872.  
  1873.         Integer gadgets are a special sort of string gadgets which accept
  1874.         the input of a decimal number.Intuition converts the value into a 
  1875.         long word and sends it to the program.
  1876.  
  1877.         Proportional gadgets let you choose an analog value with the mouse
  1878.         You can move these around with the mouse.
  1879.  
  1880.       7.9.1.Boolean Gadgets.
  1881.       ----------------------
  1882.         Lets start with the simplest type,the boolean gadget.an example of
  1883.         this sort of gadget is the close symbol of the window.The only
  1884.         status it differenciates between are clicked and not clicked.Lets 
  1885.         develop a gadget of this type step by step.The flags and other    
  1886.         parameters are similar for the other gadgets.
  1887.         Each gadget needs a structure containing fifteen entries.There is
  1888.         a pointer to this structure in window,screen or requester that the
  1889.         gadget is to appear in.Theres always a long word available for
  1890.         this purpose.Up to this point,you've just put a zero there.If
  1891.         there is an address of a gadget structure there,the gadget or
  1892.         gadgets are displayed when the window is opened.
  1893.  
  1894.         A gadget structure as the following entries:
  1895.  
  1896.         The first long word is a pointer to the next gadget to be
  1897.         installed.The gadgets are displayed in a row,like pearls on a
  1898.         string.This pointer is the first gadget in this linked list of
  1899.         gadgets.If you just want one gadget in your window,put a zero
  1900.         here:
  1901.        
  1902.         gadget1:
  1903.                dc.l  0                  ;no more gadgets
  1904.  
  1905.         The next two words determine the position of the gadget in the
  1906.         window.There are several ways to determine the position.Use flags 
  1907.         to access the various possibilities.Lets start with a gadget that 
  1908.         stays in one spot:
  1909.  
  1910.                dc.w  40                 ;X and
  1911.                dc.w  50                 ;Y position of the gadget
  1912.  
  1913.         The next two words determine the size of the gadgets Hit box.This 
  1914.         box isn't the visible size of the gadget (that depends on the
  1915.         image data).It is the size of the rectangle that Intuition should 
  1916.         watch.If the mouse pointer is moved into this box and the left
  1917.         button pressed,the gadget is activated.Clicking on parts of the
  1918.         gadget that are outside this box have no effect!
  1919.  
  1920.                dc.w  32                 ;width and
  1921.                dc.w  13                 ;height of the hit box
  1922.  
  1923.         Next comes the word whose bits determine the properties of the
  1924.         gadget.Bits 0 and 1 determine what should happen when this objects
  1925.         hit box is clicked on.The meanings of the various values of these
  1926.         bits go as follows:
  1927.  
  1928.         Bit 0   1   Value   Name          Meaning
  1929.         ------------------------------------------------------------------
  1930.          0      0     0     GADGHCOMP     The gadget inverted
  1931.          0      1     1     GADGHBOX      The gadget framed
  1932.          1      0     2     GADGHIMAGE    Another image appears
  1933.          1      1     3     GADGHNONE     No reaction
  1934.  
  1935.         Bit 2 determines whether the gadget should consist of a drawing or
  1936.         a border.If it is set(Value+4),it is treated as an image;otherwise
  1937.         its treated like a border.
  1938.         The next bit determines if the gadget should appear in the upper
  1939.         or lower border of the frame.If it is set(Value+8).the position is
  1940.         relative to the lower border;otherwise it is relative to the upper
  1941.         border.The next bit as the same meaning for the horizontal
  1942.         position.If set(Value+$10),it is a relative positioning.Otherwise,
  1943.         it is an absolute positioning.
  1944.         Notice that when you define a gadget to be relative,you must have
  1945.         a negative value in the position input in the first word of the
  1946.         structure.Since the desired position isn't under,but its over this
  1947.         position!
  1948.         In this way,you can choose either absolute or relative positioning
  1949.         of the gadget.An example of a gadget that is positioned absolutely
  1950.         is the system gadget,close window.An example of a relative gadget 
  1951.         is the symbol for changing the size.
  1952.         The width and height of the gadgets hit box can also be relative
  1953.         to the window size.Specify this by using bit 5 for width (Value +
  1954.         $20)and bit 6 for the height (Value +$40).A set bit mens a
  1955.         relative size.
  1956.         Bit 7 (Value+$80)makes the object active as soon as the window is
  1957.         opened.
  1958.         Bit 8 (Value+$100)determines whether the gadget can be used or not
  1959.         If this bit is set,the gadget can't be activated.
  1960.         For the example,you'll use absolute positioning and size,the
  1961.         inverted appearance for the activated gadget,and the
  1962.         representation of the object as an image.That means you must use
  1963.         the value four:
  1964.  
  1965.               dc.w  4              ;flags:image,invert
  1966.  
  1967.         Next comes a word whose bits are used as flags.This flag is called
  1968.         the Activation Flag.It determines the functions of the gadget.The 
  1969.         bits,their values and meanings follow:
  1970.  
  1971.         Bit   Value   Name            Meaning
  1972.         ------------------------------------------------------------------
  1973.          0     1      RELVERIFY       Causes the gadget to be activated
  1974.                                       only when the left mouse key is let
  1975.                                       loose over the gadget.
  1976.          1     2      GADGIMMEDIATE   Lets the gadget be active as soon as
  1977.                                       there is a click.
  1978.          2     4      ENDGADGET       Lets you choose to end this choice
  1979.                                       and have it disappear if this is a  
  1980.                                       requester gadget.
  1981.          3     8      FOLLOWMOUSE     Lets the gadget know the mouse
  1982.                                       position at regular intervals from
  1983.                                       the time it is selected until the
  1984.                                       time it is deselected.You can use
  1985.                                       this to move the gadget with the
  1986.                                       mouse when you want to change the
  1987.                                       gadget position.
  1988.          4     $10    RIGHTBORDER     This makes sure thay when borders
  1989.                                       are used that the page is adjusted
  1990.                                       to the size of the gadget so that it
  1991.                                       fits in the border.
  1992.          5     $20    LEFTBORDER
  1993.          6     $40    TOPBORDER
  1994.          7     $80    BOTTOMBORDER
  1995.          8     $100   TOGGLESELECT    Allows the objects state to change  
  1996.                                       every time it is clicked.If
  1997.                                       activated,it becomes deactivated and
  1998.                                       vice versa.
  1999.          9     $200   STRINGCENTRE    For a string gadget,these two bits  
  2000.                                       determine whether the string should 
  2001.                                       appear centred or right justified.If
  2002.                                       neither is set,the string is output 
  2003.                                       left justified.
  2004.          10    $400   STRINGRIGHT
  2005.          11    $800   LONGINT         Turns a string gadget into a Integer
  2006.                                       gadget (explanation later).
  2007.          12    $1000  ALTKEYMAP       Causes another ketboard placement to
  2008.                                       be in effect for string gadget input
  2009.  
  2010.         Thats it for the activation flags.Lets choose the TOGGLESELECT and
  2011.         GADGETIMMEDIATED flags for example:
  2012.  
  2013.              dc.w  $102             ;activation
  2014.  
  2015.         The next word of the gadget structure determines the gadget type. 
  2016.         Heres the meaning of the individual bits:
  2017.  
  2018.         Bit   Value   Name            Meaning(report what circumstances)
  2019.         ----------------------------------------------------------------
  2020.          0     1      BOOLGADGET      This is a boolean gadget
  2021.          1     2      GADGET002       
  2022.          2     4      STRGADGET       String order Integer gadget
  2023.         0+1    3      PROPGADGET      Proportional gadget
  2024.  
  2025.         System gadgets:
  2026.          4     $10    SIZING          Size changing gadget
  2027.          5     $20    WDRAGGING       Moving gadget for window
  2028.         4+5    $30    SDRAGGING       Same for screen
  2029.          6     $40    WUPFRONT        Gadget to move window forward
  2030.         6+4    $50    SUPFRONT        Gadget to move screen forward
  2031.         6+5    $60    WDOWNBACK       Move window back
  2032.         6+5+4  $70    SDOWNBACK       Move screen back
  2033.          7     $80    CLOSE           Window close gadget
  2034.  
  2035.         Type definitions:
  2036.          12    $1000  REQGADGET       Requester gadget
  2037.          13    $2000  GZZGADGET       Border gadget in GIMMEZEROZERO
  2038.                                       window
  2039.          14    $4000  SCRGADGET       Screen gadget when set
  2040.          15    $8000  SYSGADGET       System gadget when set
  2041.  
  2042.         You want to use a simple boolean gadget for your example,so enter:
  2043.  
  2044.                dc.w  1                ;gadget type:boolean
  2045.  
  2046.         Next comes a pointer to the gadget structure.The first pointer
  2047.         contains the address of the image or border structure which should
  2048.         be used to represent the gadget.If no representation is needed,put
  2049.         a zero here.You want to represent the gadget as an image,so put a 
  2050.         pointer to the image structure that you produced in the chapter
  2051.         about images:
  2052.  
  2053.                dc.l  image            ;gadget image
  2054.  
  2055.         The next pointer is only used if the GADGHIMAGE flag in the flag
  2056.         word of the structure is set.This is a pointer to another
  2057.         structure that should be put on the screen when the object is
  2058.         activated.If a border structure is used for the gadget represent- 
  2059.         ation,this must be a border structure as well.You won't use a
  2060.         second image,so put a zero here:
  2061.  
  2062.                dc.l  0                ;no new gadget displayed
  2063.  
  2064.         The next pointer is to the text structure that should be output by
  2065.         the gadget.If no text is needed,just put a zero here.You want to
  2066.         use some text,however:
  2067.  
  2068.                dc.l  ggtext           ;gadget text
  2069.  
  2070.         Now comes a long word that determines which gadgets are
  2071.         deactivated when this is activated.This function still doesn't
  2072.         work right so put a zero here:
  2073.  
  2074.                dc.l  0                ;no exclude
  2075.  
  2076.         You'll set the next pointer to zero as well,because it is only
  2077.         used for String and Proportional gadgets.For these gadgets,this is
  2078.         a special structure to describe the characteristics of the gadget.
  2079.         Its called SpecialInfo.
  2080.  
  2081.                dc.l  0                ;no SpecialInfo
  2082.  
  2083.         The next word contains the Gadget Identification (ID) number:
  2084.  
  2085.                dc.w  1                ;gadget ID
  2086.  
  2087.         Finally there is a long word that doesn't have any function,so put
  2088.         a zero here:
  2089.  
  2090.                dc.l  0                ;user data (ignore)
  2091.  
  2092.         Thats it.Heres a quick overview of the gadget structure:
  2093.  
  2094.         gadget1:
  2095.                dc.l  0                ;no more gadgets
  2096.                dc.w  40               ;X and
  2097.                dc.w  50               ;Y position of gadget
  2098.                dc.w  32               ;width and
  2099.                dc.w  13               ;height of hit box
  2100.                dc.w  4                ;flags:image,invert
  2101.                dc.w  $102             ;activation flags
  2102.                dc.w  1                ;gadget type:boolean
  2103.                dc.l  image            ;gadget image
  2104.                dc.l  0                ;no new gadget displayed
  2105.                dc.l  ggtext           ;gadget text
  2106.                dc.l  0                ;no exclude
  2107.                dc.l  0                ;no SpecialInfo
  2108.                dc.w  1                ;gadget ID
  2109.                dc.l  0                ;user data (ignore)
  2110.  
  2111.         You've already prepared a structure that you can use for this
  2112.         image.Now you need the text that appears under the gadget.
  2113.         Since the gadget looks like a switch,label it "switch".The text
  2114.         structure looks like this:
  2115.  
  2116.         ggtext:
  2117.                dc.b  1,0              ;colours
  2118.                dc.b  1                ;mode
  2119.            align
  2120.                dc.w  -8,14            ;X and Y position
  2121.                dc.l  0                ;standard font
  2122.                dc.l  swtext           ;pointer to text
  2123.                dc.l  0                ;no more text
  2124.         swtext:
  2125.                dc.b  "switch",0
  2126.            align
  2127.  
  2128.         Once you've typed this in,save it,assemble it and start again.You 
  2129.         can click the switch and cause it to be inverted.Click it again,  
  2130.         and it appears normal.
  2131.         Now you can experriment with the structure.If you change the flag 
  2132.         from four to five,you can cause the gadget to be framed when it is
  2133.         activated.Set the RELVERIFY bit(bit0:+1)in the Activation Flag
  2134.         word.Then you can move the mouse pointer onto the object and press
  2135.         the button.It is activated.Keep the mouse button pressed down and 
  2136.         move the mouse.Once you leave the hit box,the activation disapears
  2137.         This way,you can avoid accidently activating a gadget.
  2138.         Now you want to display the switch in an on state.This is easy.All
  2139.         you need to do is produce another image structure,one for the on  
  2140.         state.You put this pointer in the long word right after the
  2141.         pointer to the normal image structure.You can change the flag word
  2142.         to six which causes a second image to be displayed when the gadget
  2143.         is activated.
  2144.         Here is the image structure for the switch in the one state.
  2145.  
  2146.         image2:
  2147.                dc.w  0,0              ;no offset
  2148.                dc.w  32,13            ;32x13 pixels
  2149.                dc.w  1                ;mode 1
  2150.                dc.l  imgdata2         ;pointer to the data
  2151.                dc.b  2,1              ;same colours as before
  2152.                dc.l  0                ;nothing else
  2153.        
  2154.         imgdata2:                     ;data for switch in the On state
  2155.                dc.l  %00000000000000000000000000000000
  2156.                dc.l  %00000000011100000000000000000000
  2157.                dc.l  %00000000111110000011101001000000
  2158.                dc.l  %00000000111110000010101101000000
  2159.                dc.l  %00000000011110000010101011000000
  2160.                dc.l  %00000000000111000011101001000000
  2161.                dc.l  %00000000000011100000000000000000
  2162.                dc.l  %00000000000001110000000000000000
  2163.                dc.l  %00000000000111111111100000000000
  2164.                dc.l  %00000000001111111111110000000000
  2165.                dc.l  %00000000001111111111110000000000
  2166.                dc.l  %00000000000110000001100000000000
  2167.                dc.l  %00000000000000000000000000000000
  2168.  
  2169.         Now the state of the object can be determined by looking at the
  2170.         picture.If the gadget is activated,the switch is on.If not,the
  2171.         switch is off.
  2172.         Thats it for boolean gadgets.You can learn about the things you
  2173.         did'nt touch with some experimentation.You want to get to the
  2174.         string gadgets that also do some interesting things.
  2175.  
  2176.       7.9.2.String Gadgets.
  2177.       ---------------------
  2178.         Lets pretend you want a program to load data from the disk.To get 
  2179.         the user to enter the filename,you need to output text telling the
  2180.         user to enter the name.Then you need to call an input routine to
  2181.         evaluate the keyboard input.
  2182.         Its easier and more elegant to use a String gadget.This function  
  2183.         allows for easy input and/or editingof short text.You have the
  2184.         option of having the text framed.The Undo function can be used by 
  2185.         pressing the right <Amiga> key and a "Q",and the old contents of
  2186.         the gadget,the old text are restored.
  2187.         You can also vary the size of the text and the input field.If the 
  2188.         text is longer than the input field is wide,the text is moved back
  2189.         and forth through the visible area when you move the cursor keys
  2190.         or the normal input to the border.
  2191.         You can also restrict input to just digits.This makes it posible
  2192.         to accept numeric input.Intuition even converts the digit string  
  2193.         into a binary number.This saves the machine language programmer
  2194.         some work.A specialized String gadget of this sort is called a    
  2195.         Integer gadget.
  2196.         The structure is similar to the Boolean gadgets structure.There
  2197.         are only two major differences:
  2198.  
  2199.         The type word of the structure must be a four to declare that this
  2200.         is a String gadget (STRGADGET).
  2201.   
  2202.         The pointer to the SpecialInfo structure is needed.Put a pointer
  2203.         to the StringInfo structure that you are going to design later
  2204.         here.
  2205.  
  2206.         The width and height entries in the gadget structure have a
  2207.         different meaning than they had previously.They do declare the
  2208.         area in which you can bring the mouse pointer to activate the
  2209.         String gadget.However,it is also used for representation of text. 
  2210.         These values determine the size of the box in which the text is
  2211.         output.You should surround the box with a border using the Border 
  2212.         function,so that the user can see where it is.
  2213.         If the text is longer than the box,only a portion of it is seen on
  2214.         the screen.You can move through the area by entering text or using
  2215.         the left/right cursor keys to move through the box.The characters 
  2216.         that are entered are inserted at the cursor position,so the rest
  2217.         of the text is shifted by one character when you are on the right 
  2218.         edge of the input area.The following functions can be used for
  2219.         editing this text:
  2220.  
  2221.         Cursor key left/right
  2222.               Moves the cursor over the text thats already on hand.Moves
  2223.               the text through the Container.
  2224.  
  2225.         Cursor keys with <Shift>
  2226.               Puts the cursor on the beginning or the end of the text.
  2227.  
  2228.         <Del> Deletes the character under the cursor.
  2229.  
  2230.         <Backspace>
  2231.               Deletes the character to the left of the cursor.
  2232.  
  2233.         <Return>
  2234.               Ends text input.
  2235.  
  2236.         <Amiga>right+"Q"
  2237.               This is the Undo function.It replaces the text with the
  2238.               original contents.
  2239.  
  2240.         The StringInfo structure only has a few entries:
  2241.  
  2242.         First theres a pointer to the memory area that is used to store
  2243.         the text that is input.The memory buffer must be big enough to
  2244.         handle all the text entered.
  2245.  
  2246.         strinfo:
  2247.                dc.l  strpuffer        ;pointer to text buffer
  2248.  
  2249.         Next comes the pointer to the Undo buffer.This pointer and this
  2250.         buffer are only needed if you want the Undo function.If you do,you
  2251.         must have a buffer that is at least as big as your text buffer.   
  2252.         Every time the string gadget function is called,the text buffers  
  2253.         contents are copied into this buffer.To get the old contents back,
  2254.         just press the right <Amiga>key and the "Q"key.The contents of the
  2255.         Undo buffer are copied back to the text buffer.If you use several 
  2256.         string gadgets in a program,you can use the same Undo buffer for
  2257.         all of them,since only one string gadget is used at one time.
  2258.  
  2259.                dc.l  undo             ;pointer to undo buffer
  2260.  
  2261.         The following word contains the cursor position in the text.You   
  2262.         should set this word to zero,so that the user can see the
  2263.         beginning of the text when the string gadget appears.
  2264.  
  2265.                dc.w  0                ;cursor position
  2266.  
  2267.         The next word contains the maximum number of characters that can
  2268.         be input.If you type one more than this number of characters,the  
  2269.         screen blinks,to show that you can't enter a longer input string. 
  2270.         The number of characters and the reserved space for the input
  2271.         field don't have to agree,since text can be scrolled by typing.
  2272.  
  2273.                dc.w  10               ;maximum # of characters
  2274.  
  2275.         The following word tells at which character of text in the buffer,
  2276.         the output to the box should begin.You should put a zero here,so
  2277.         that the user can see the beginning of the text.
  2278.  
  2279.                dc.w  0                ;output text from this character
  2280.  
  2281.         The next five words are used by Intuition,so you don't have to    
  2282.         initialize them.Just put zeros here.The words contain the
  2283.         following information:
  2284.  
  2285.                dc.w  0                ;character position in undo buffer
  2286.                dc.w  0                ;number of chars in text buffer
  2287.                dc.w  0                ;number of chars visible in box
  2288.                dc.w  0                ;horizontal box offset
  2289.                dc.w  0                ;vertical box offset
  2290.  
  2291.         The next two long words are initialized by Intuition as well:
  2292.  
  2293.                dc.l  0                ;pointer to rastport
  2294.                dc.l  0                ;long word with value of the input
  2295.         ;                             ;(for integer gadgets)
  2296.  
  2297.         The final entry is a pointer to the keyboard table that is used if
  2298.         the ALTKEYMAP flag of the gadget is set.
  2299.  
  2300.                dc.l  0                ;standard keyboard table
  2301.  
  2302.         Heres a quick overview of the StringInfo structure:
  2303.  
  2304.         strinfo:
  2305.                dc.l  strpuffer        ;pointer to text buffer
  2306.                dc.l  undo             ;pointer to undo buffer
  2307.                dc.w  0                ;cursor position
  2308.                dc.w  10               ;maximum # of characters
  2309.                dc.w  0                ;output text from this character
  2310.                dc.w  0                ;character position in undo buffer
  2311.                dc.w  0                ;number of chars in text buffer
  2312.                dc.w  0                ;number of chars visible in box
  2313.                dc.w  0                ;horizontal box offset
  2314.                dc.w  0                ;vertical box offset
  2315.                dc.l  0                ;pointer to rastport
  2316.                dc.l  0                ;long word with value of input
  2317.         ;                             ;(for integer gadgets)
  2318.                dc.l  0                ;standard keyboard table
  2319.  
  2320.         Here are the text and undo buffers:
  2321.  
  2322.         strpuffer:
  2323.                dc.b  "Hello!",0,0,0
  2324.  
  2325.         undo:
  2326.                dc.l  0,0,0,0
  2327.            align
  2328.  
  2329.         Once you've entered these lines,you can either alter the old
  2330.         gadget structure or build a new one.We'd recommend building
  2331.         another gadget structure so that you can have the switch and use
  2332.         it later.Change the first pointer in the old structure from zero
  2333.         to "gadget1"and insert this new structure.Here is an example
  2334.         strucure for the string gadget.It as the following entries:
  2335.  
  2336.         gadget1:                      ;*structure for string gadget
  2337.                dc.l  0                ;no more gadgets
  2338.                dc.w  20,80            ;position
  2339.                dc.w  80,10            ;width and height of box
  2340.                dc.w  0                ;flags:normal
  2341.                dc.w  2                ;activation($802 for long int)
  2342.                dc.w  4                ;type:string gadget
  2343.                dc.l  border           ;pointer to border
  2344.                dc.l  0                ;no drawing selected
  2345.                dc.l  0                ;no text
  2346.                dc.l  0                ;no exclude
  2347.                dc.l  strinfo          ;pointer to stringinfo structure
  2348.                dc.w  2                ;gadget ID
  2349.                dc.l  0                ;no user data
  2350.  
  2351.         border:                       ;*border for box frame
  2352.                dc.w  0,0              ;no offset
  2353.                dc.b  3,3              ;red colour
  2354.                dc.b  0                ;mode:JAM1
  2355.                dc.b  5                ;5 X,Y pairs
  2356.                dc.l  coord            ;pointer to coordinates table
  2357.                dc.l  0                ;no more structures
  2358.  
  2359.         coord:                        ;*coordinates for frame
  2360.                dc.w  -2,-2            ;start in upper left corner
  2361.                dc.w  80,-2            ;upper right
  2362.                dc.w  80,9             ;lower right
  2363.                dc.w  -2,9             ;lower left
  2364.                dc.w  -2,-2            ;back to beginning
  2365.  
  2366.         This data causes a red rectangle,the border,to appear around the  
  2367.         "Hello!"text.You can change the text by clicking in the field and 
  2368.         editing once the cursor appears.If you type something wrong,you
  2369.         can use the undo function(the right <Amiga> key and the Q key),to 
  2370.         get "Hello!"back.
  2371.         Once you've done some typing and deactivated the gadget by
  2372.         pressing <Return> or by clicking outside the field (cursors
  2373.         disapear),you can terminate the program.
  2374.         Change the activation flag to $802 and the "strbuffer"to "dc.l
  2375.         0,0,0,0",assemble,and then start the program.You can type in the
  2376.         string gadget once it has been activated,but you can only enter
  2377.         digits.The screen blinks if you enter letters.
  2378.         Enter a number,and then end the program after deactivating the
  2379.         gadget.If you look at the stringinfo structure you can look at the
  2380.         value of the number you input(in hex)in the eight long word.
  2381.         After looking at boolean,text and numeric input to gadgets,lets
  2382.         look at Proportional gadgets which allow the user to enter analog 
  2383.         values by moving a symbol.
  2384.  
  2385.       7.9.3.Proportional Gadgets.
  2386.       ---------------------------
  2387.         You've seen the advantages of slider devices over knobs that you
  2388.         turn,maybe on a hifi,maybe on a toaster,but certainly someplace.
  2389.         Its easier to tell the state the item is in with a slider,
  2390.         especially if several such devices are next to each other(for
  2391.         example graphic equalizers).You can represent sliders on the
  2392.         Amigas screen and work with them with the mouse.This offers a nice
  2393.         way to represent information graphically in your programs.
  2394.         You can do this with gadgets.Using Proportional gadgets,you can
  2395.         put a symbol in a frame and move horzontally and/or vertically.The
  2396.         size of the frame and the slider can be variable size,so that the
  2397.         frame size is relative to the screen size so when the window
  2398.         changes size,it will also.The slider can be set up so that its
  2399.         size in the grows or shrinks.
  2400.         These are best seen via example and experimentation.(The
  2401.         posibilities mentioned do not form a complete list by any stretch 
  2402.         of the imagination.)You want to set up a simple Proportional
  2403.         gadget that can be moved horizontally.
  2404.         You need a gadget structure that as the same form as others.To
  2405.         show the differences,heres a complete example structure for your  
  2406.         gadget.You can connect this gadget to the other one,by changing
  2407.         the first long word in the last structure to "dc.l gadget2".
  2408.  
  2409.         gadget2:                      ;*structure for Proportional gadget
  2410.                dc.l  0                ;no more gadgets
  2411.                dc.w  150,30           ;position
  2412.                dc.w  100,10           ;width and height of frame
  2413.                dc.w  4                ;flags:GADGIMAGE
  2414.                dc.w  2                ;activation:GADGIMMEDIATE
  2415.                dc.w  3                ;type:proportional gadget
  2416.                dc.l  mover            ;pointer to slider data
  2417.                dc.l  0                ;no select structure
  2418.                dc.l  0                ;no text
  2419.                dc.l  0                ;no exclude
  2420.                dc.l  propinfo         ;pointer to propinfo structure
  2421.                dc.w  3                ;gadget ID
  2422.                dc.l  0                ;no user data
  2423.  
  2424.         You see two special features.Use an image structure for the mover 
  2425.         and put a pointer to another structure in the spot for the Special
  2426.         Info pointer.
  2427.         First,lets look at the "mover"structure,the sliders image
  2428.         structure.Heres an example of this structure:
  2429.  
  2430.         mover:                        ;*structure for slider image
  2431.                dc.w  0,0              ;no offset
  2432.                dc.w  16,7             ;16x7 pixels big
  2433.                dc.w  1                ;one bit plane
  2434.                dc.l  moverdata        ;pointer to image data
  2435.                dc.b  1,0              ;colour:white
  2436.                dc.l  0                ;don't continue
  2437.  
  2438.         moverdata:                    ;*image data for mover
  2439.                dc.w %0111111111111110
  2440.                dc.w %0101111111111010
  2441.                dc.w %0101011111101010
  2442.                dc.w %0101010110101010
  2443.                dc.w %0101011111101010
  2444.                dc.w %0101111111111010
  2445.                dc.w %0111111111111110
  2446.  
  2447.         Up till now,there was'nt anything new.Now lets look at the
  2448.         PropInfo structure that describes the properties of the
  2449.         Proportional gadget.
  2450.  
  2451.         The structure starts with a flag word that contains the following 
  2452.         bits:
  2453.  
  2454.         Bits   Value   Name              Meaning
  2455.         -----------------------------------------------------------------
  2456.          0       1     AUTOKNOB          Mover is set up automatically
  2457.          1       2     FREEHORIZ         Allows horizontal movement
  2458.          2       4     FREEVERT          Allows vertical movement
  2459.          3       8     PROPBORDERLESS    Turns off automatic framing
  2460.          8      $100   KNOBHIT           Set when the mover is touched
  2461.  
  2462.         You can set the first four bits to get the representation that you
  2463.         want.Bit 8 is set by Intuition when the mover is clicked with the
  2464.         mouse pointer.
  2465.         Bit 0,AUTOKNOB,allos for the simplest sort of Proportional gadget.
  2466.         If this bit is set,no move data are used for the mover image.
  2467.         Instead,a white mover is generated that is adjusted to the size of
  2468.         the box and the values to be represented.When you use this slider
  2469.         to represent the displayed lines in a long text of a program,the
  2470.         displayed lines are a percentage of the total text.The
  2471.         relationship between the total number of lines and the lines shown
  2472.         is represented by an AUTOKNOB as the relationship between the
  2473.         frame and the slider.The bigger the percentage,the bigger the
  2474.         slider is.You don't want to work with this though,even though it
  2475.         is simple and interesting,because a simple white button isn't
  2476.         particularly attractive.If you experiment with it,make sure that
  2477.         the pointer to the image data points to a four word long buffer
  2478.         that Intuition can use to store values.The buffer is of the
  2479.         following form:
  2480.  
  2481.         buffer:
  2482.                dc.w  0                ;X position of the slider in the box
  2483.                dc.w  0                ;Y position in the box
  2484.                dc.w  0                ;width of slider
  2485.                dc.w  0                ;height of slider
  2486.  
  2487.         Leys look at the PropInfo structure.Since you're not using
  2488.         AUTOKNOB and wish to allow horizontal movement only,put two in as
  2489.         a flag:
  2490.  
  2491.         propinfo:
  2492.                dc.w  2                ;flags:FREEHORIZ
  2493.  
  2494.         In the next two words of the structure,the horizontal (HorizPot)
  2495.         and vertical (VertPot) position of sliders are stored.A value of  
  2496.         zero means left or upper,while the value $FFFF means right or
  2497.         lower.The value that results from movement is in this range.You
  2498.         set these values to zero at the start of the program.After moving 
  2499.         the mouse,there is different values here.
  2500.  
  2501.                dc.w  0,0              ;X and Y position of the slider
  2502.  
  2503.         Next come two words which determine the size of the AUTOKNOB or
  2504.         the step size of the slider(this determines how far the slider
  2505.         moves when you click in the box next to the slider).These words
  2506.         are called HorizBody (horizontal movement) and VertBody (vertical 
  2507.         movement).
  2508.  
  2509.                dc.w  $ffff/16         ;horizontal step size:1/16
  2510.                dc.w  0                ;no vertical movement
  2511.         ;The next six words are initialized by Intuition.
  2512.                dc.w  0                ;box width
  2513.                dc.w  0                ;box height
  2514.                dc.w  0                ;absolute step size horizontal
  2515.                dc.w  0                ;and vertical
  2516.                dc.w  0                ;left border of box 
  2517.                dc.w  0                ;upper border of box
  2518.  
  2519.         Thats it.Heres a quick overview of the PropInfo structure:
  2520.          
  2521.         prpoinfo:
  2522.                dc.w  2                ;flags:FREEHORIZ
  2523.                dc.w  0,0              ;X and Y position of slider
  2524.                dc.w  $ffff/16         ;horizontal step size:1/16
  2525.                dc.w  0                ;no vertical movement
  2526.                dc.w  0                ;box width
  2527.                dc.w  0                ;box height
  2528.                dc.w  0                ;absolute step size horizontal
  2529.                dc.w  0                ;and vertical
  2530.                dc.w  0                ;left border of box
  2531.                dc.w  0                ;upper border of box
  2532.  
  2533.         Once you've typed this in,you can start the program and try it
  2534.         out.
  2535.         You can also try vertical movement by setting the flag word equal
  2536.         to six,the vertical step size to $FFFF/10,and the height of the
  2537.         gadget to 80,for the example.To try out the AUTOKNOBs,change the  
  2538.         flag value to seven.
  2539.  
  2540.       7.10.Example Program.
  2541.       ---------------------
  2542.         Here is a complete example program using what you have learned in
  2543.         this chapter:
  2544.  
  2545.         ;7_Intuition.asm
  2546.         ;** Demo-Program for working with Intuition **
  2547.  
  2548.         movescreen    =-162
  2549.         openscreen    =-198
  2550.         closescreen   =-66
  2551.         openwindow    =-204
  2552.         closewindow   =-72
  2553.         autorequest   =-348
  2554.         setmenustrip  =-264
  2555.         clearmenustrip=-54
  2556.         printitext    =-216
  2557.         drawimage     =-144
  2558.         drawborder    =-108
  2559.         displaybeep   =-96
  2560.         closelibrary  =-414
  2561.         openlib       =-408
  2562.         execbase      = 4
  2563.         getmsg        =-372
  2564.  
  2565.         joy2          =$dff0c
  2566.         fire          =$bfe001
  2567.  
  2568.         ;!!!when > 500kb !!!
  2569.         ;org $40000
  2570.         ;load $40000
  2571.         ; or use AssemPro to place in CHIP RAM
  2572.         ;!!!!!!!!!!!!!!!!!!!!!!!
  2573.  
  2574.         run:   
  2575.                bsr     openint
  2576.                bsr     scropen
  2577.                bsr     windopen
  2578.                bsr     setmenu
  2579.                bsr     print
  2580.  
  2581.                lea     border,a1
  2582.                move    #22,d0
  2583.                move    #30,d1
  2584.                bsr     borderdraw
  2585.               
  2586.                bsr     draw
  2587.                
  2588.                bsr     request
  2589.  
  2590.         loop:
  2591.                move.l  execbase,a6
  2592.                move.l  windowhd,a0
  2593.                move.l  86(a0),a0        ;user port
  2594.                jsr     getmsg(a6)
  2595.                tst.l   d0
  2596.                beq     loop             ;no event
  2597.                move.l  d0,a0
  2598.                move.l  $16(a0),msg      ;event:LO=item,HI=Event
  2599.                move.l  msg,d6           ;to test
  2600.                move.l  d6,d7
  2601.                lsr     #8,d7
  2602.                lsr     #3,d7            ;sub menu point in D7
  2603.                clr.l   d5
  2604.                roxr    #1,d6
  2605.                roxl    #1,d5            ;menu number in D5
  2606.                and.l   #$7f,d6
  2607.                cmp     #$7f,d6          ;no menu point?
  2608.                beq     loop             ;no:continue
  2609.                lsr     #4,d6            ;menu point in D6
  2610.                cmp     #1,d6            ;point 2?
  2611.                bne     no1
  2612.                move,l  intbase,a6
  2613.                move.l  screenhd,a0
  2614.                jsr     displaybeep(a6)
  2615.  
  2616.         no1:
  2617.                cmp     #0,d6
  2618.                bne     loop
  2619.  
  2620.         ende:
  2621.                bsr     clearmenu
  2622.                bsr     windclose
  2623.                bsr     scrclose
  2624.                bsr     closeint
  2625.                rts
  2626.  
  2627.         openint:
  2628.                move.l  execbase,a6
  2629.                lea     intname,a1
  2630.                jsr     openlib(a6)
  2631.                move.l  d0,intbase
  2632.                rts
  2633.  
  2634.         closeint:
  2635.                move.l  execbase,a6
  2636.                move.l  intbase,a1
  2637.                jsr     closelibrary(a6)
  2638.                rts
  2639.  
  2640.         scropen:
  2641.                move.l  inbase,a6
  2642.                lea     screen_defs,a0
  2643.                jsr     openscreen(a6)
  2644.                move.l  d0,screenhd
  2645.  
  2646.         scrclose:
  2647.                move.l  inbase,a6
  2648.                move.l  screenhd,a0
  2649.                jsr     closescreen(a6)
  2650.                rts
  2651.  
  2652.         scrmove:
  2653.                move.l  intbase,a6
  2654.                move,l  screenhd,a0
  2655.                jsr     movescreen(a6)
  2656.                rts
  2657.  
  2658.         windopen:
  2659.                move.l  intbase,a6
  2660.                lea     windowdef,a0
  2661.                jsr     openwindow(a6)
  2662.                move.l  d0,windowhd
  2663.                rts
  2664.  
  2665.         windclose:
  2666.                move.l  intbase,a6
  2667.                move.l  windowhd,a0
  2668.                jsr     closewindow(a6)
  2669.                rts
  2670.  
  2671.         request:
  2672.                move.l  windowhd,a0
  2673.                lea     btext,a1
  2674.                lea     ltext,a2
  2675.                lea     rtext,a3
  2676.                move.l  #0,d0
  2677.                move.l  #0,d1
  2678.                move.l  #180,d2
  2679.                move.l  #80,d3
  2680.                move.l  intbase,a6
  2681.                jsr     autorequest(a6)
  2682.                rts
  2683.  
  2684.         setmenu:
  2685.                lea     mentab,a0        ;pointer to text pointer in A0
  2686.                lea     menu,a1          ;pointer to menu field in A1
  2687.                move    #10,d1           ;menu position = 10
  2688.  
  2689.         menuloop:
  2690.                clr.l   d2               ;menu point-Y=0
  2691.                move.l  a1,a2            ;save pointer
  2692.                tst.l   (a0)
  2693.                beq     setmenu1         ;end
  2694.                clr.l   (a1)+
  2695.                move    d1,(a1)+
  2696.                add.l   #70,d1
  2697.                move.l  #50,(a1)+
  2698.                move.l  #$a0001,(a1)+
  2699.                move.l  (a0)+,(a1)+      ;menu title
  2700.                lea     12(a1),a3
  2701.                move.l  a3,(a1)+         ;menu point
  2702.                clr.l   (a1)+
  2703.                clr.l   (a1)+
  2704.  
  2705.         itemloop:
  2706.                tst.l   (a0)             ;last one?
  2707.                beq     menuend          ;yes
  2708.                lea     54(a1),a3
  2709.                move.l  a3,(a1)+         ;pointer to next point
  2710.                move.l  d2,(a1)+         ;X/Y
  2711.                add     #10,d2
  2712.                move.l  #$5a000a,(a1)+   ;width/height
  2713.                move    #$52,(a1)+
  2714.                clr.l   (a1)+
  2715.                lea     16(a1),a3
  2716.                move.l  a3,(a1)+         ;text structor-pointer
  2717.                clr.l   (a1)+
  2718.                clr.l   (a1)+
  2719.                clr.l   (a1)+
  2720.  
  2721.                move    #$1,(a1)+        ;text-structor set
  2722.                clr     (a1)+
  2723.                move.l  #$50003,(a1)+
  2724.                clr.l   (a1)+
  2725.                move.l  (a0)+,(a1)+      ;text pointer
  2726.                clr.l   (a1)+
  2727.  
  2728.                bra     itemloop         ;next point...
  2729.  
  2730.         menuend:
  2731.                clr.l   -54(a1)
  2732.                tst.l   (a0)+
  2733.                tst.l   (a0)             ;still in menu?
  2734.                beq     setmenu1         ;no:ready
  2735.                move.l  a1,(a2)          ;pointer to next menu
  2736.                bra     menuloop         ;and continue
  2737.  
  2738.         setmenu1:
  2739.                move.l  intbase,a6
  2740.                move.l  windowhd,a0
  2741.                lea     menu,a1
  2742.                jsr     setmenustrip(a6)
  2743.                rts
  2744.  
  2745.         clearmenu:
  2746.                move.l  intbase,a6
  2747.                move.l  windowhd,a0
  2748.                jsr     clearmenustrip(a6)
  2749.                rts
  2750.  
  2751.         print:
  2752.                move.l  intbase,a6
  2753.                move.l  windowhd,a0
  2754.                move.l  50(a0),a0
  2755.                lea     ggtext,a1
  2756.                move.l  #30,d0           ;X
  2757.                move.l  #16,d1           ;Y
  2758.                jsr     printitext(a6)
  2759.                rts
  2760.  
  2761.         draw:
  2762.                move.l  intbase,a6
  2763.                move.l  windowhd,a0
  2764.                move.l  50(a0),a0
  2765.                lea     image,a1
  2766.                move.l  #200,d0
  2767.                move.l  #100,d1
  2768.                jsr     drawimage(a6)
  2769.                rts
  2770.  
  2771.         borderdraw:
  2772.                move.l  intbase,a6
  2773.                move.l  windowhd,a0
  2774.                move.l  50(a0),a0
  2775.                jsr     drawborder(a6)
  2776.                rts
  2777.  
  2778.         screen_defs:
  2779.                dc.w  0,0
  2780.                dc.w  640,200
  2781.                dc.w  4
  2782.                dc.b  0
  2783.                dc.b  1
  2784.                dc.w  $800
  2785.                dc.w  15
  2786.                dc.l  0
  2787.                dc.l  tite1
  2788.                dc.l  0
  2789.                dc.l  0
  2790.  
  2791.         windowdef:
  2792.                dc.w  10,20
  2793.                dc.w  300,150
  2794.                dc.b  0,1
  2795.                dc.l  $300
  2796.                dc.l  $100f
  2797.                dc.l  gadget
  2798.                dc.l  0
  2799.                dc.l  windname
  2800.  
  2801.         screenhd:
  2802.                dc.l  0
  2803.                dc.l  0 
  2804.                dc.w  200,40,600,200
  2805.                dc.w  $f
  2806.  
  2807.         btext:
  2808.                dc.b  3,3
  2809.                dc.b  0
  2810.                align
  2811.                dc.w  10,10
  2812.                dc.l  0
  2813.                dc.l  bodytxt
  2814.                dc.l  0
  2815.       
  2816.         bodytxt:dc.b  "Requester-Text",0
  2817.                align
  2818.  
  2819.         ltext:
  2820.                dc.b  3,1
  2821.                dc.b  0
  2822.                align  dc.w 5,3
  2823.                dc.l  0
  2824.                dc.l  lefttext
  2825.                dc.l  0
  2826.  
  2827.         lefttext: dc.b "left",0
  2828.                align
  2829.  
  2830.         rtext:
  2831.                dc.b  0,1
  2832.                dc.b  0
  2833.                align  dc.w 5,3
  2834.                dc.l  0
  2835.                dc.l  righttext
  2836.                dc.l  0
  2837.  
  2838.         righttext: dc.b "right",0
  2839.                align
  2840.         tite1: dc.b  "User Screen",0
  2841.         windname: dc.b "Window-Title",0
  2842.                align  windowhd: dc.l 0
  2843.  
  2844.         intbase:dc.l  0
  2845.         intname:dc.b  "intuition.library",0
  2846.                align  msg:dc.l 0
  2847.  
  2848.         mentab:
  2849.                dc.l  menu1
  2850.                dc.l  mp11,np12,mp13,mp14,mp15,mp16,mp17,mp18,mp19,0
  2851.                dc.l  menu2
  2852.                dc.l  mp21,mp22,mp23,0
  2853.                dc.l  menu3
  2854.                dc.l  mp31,mp32,0
  2855.                dc.l  menu4,mp41,0
  2856.                dc.l  0
  2857.  
  2858.         menu1: dc.b  "Menu 1",0
  2859.         mp11:  dc.b  "Point 11",0
  2860.         mp12:  dc.b  "Point 12",0
  2861.         mp13:  dc.b  "Point 13",0
  2862.         mp14:  dc.b  "Point 14",0
  2863.         mp15:  dc.b  "Point 15",0
  2864.         mp16:  dc.b  "Point 16",0
  2865.         mp17:  dc.b  "Point 17",0
  2866.         mp18:  dc.b  "Point 18",0
  2867.         mp19:  dc.b  "Point 19",0
  2868.  
  2869.         menu2: dc.b  "Menu 2",0
  2870.         mp21:  dc.b  "End!",0
  2871.         mp22:  dc.b  "Beep",0
  2872.         mp23:  dc.b  "Point 23",0
  2873.   
  2874.         menu3: dc.b  "Menu 3",0
  2875.         mp31:  dc.b  "Point 31",0
  2876.         mp32:  dc.b  "Point 32",0
  2877.  
  2878.         menu4: dc.b  "Menu 4",0
  2879.         mp41:  dc.b  "Point 41",0
  2880.                align
  2881.  
  2882.         gadget:
  2883.                dc.l  gadget1
  2884.                dc.w  20,80,80,10
  2885.                dc.w  0
  2886.                dc.w  $2               ;activation,$802 for longint
  2887.                dc.w  4
  2888.                dc.l  border
  2889.                dc.l  0
  2890.                dc.l  0
  2891.                dc.l  0
  2892.                dc.l  strinfo
  2893.                dc.w  2
  2894.                dc.l  0
  2895.  
  2896.         border:
  2897.                dc.w  0,0
  2898.                dc.b  1,0,0
  2899.                dc.d  5               ;XY-pair
  2900.                dc.l  koord
  2901.                dc.l  0
  2902.  
  2903.         koord:
  2904.                dc.w  -2,-2,80,-2,80,9,-2,9,-2,-2
  2905.  
  2906.         strinfo:
  2907.                dc.l  strpuffer
  2908.                dc.l  undo
  2909.                dc.w  0               ;cursor position
  2910.                dc.w  10              ;max.char
  2911.                dc.w  0  
  2912.                dc.w  0,0,0,0,0
  2913.                dc.l  0,0,0
  2914.  
  2915.         strpuffer:
  2916.                dc.b  "Hello!",0,0,0
  2917.         
  2918.         undo:  dc.l  0,0,0
  2919.                align
  2920.  
  2921.         gadget1:
  2922.                dc.l  gadget2           ;more gadget
  2923.                dc.w  40,50,32,13
  2924.                dc.w  $6                ;flags:invert
  2925.                dc.w  $103              ;activate
  2926.                dc.w  1                 ;gadget type
  2927.                dc.l  image             ;gadget image
  2928.                dc.l  image2            ;select gadget
  2929.                dc.l  ggtext            ;gadget text
  2930.                dc.l  0                 ;no exclude
  2931.                dc.l  0                 ;special info
  2932.                dc.w  1                 ;ID
  2933.                dc.l  0                 ;user data
  2934.  
  2935.         ggtext:
  2936.                dc.b  1,0,1
  2937.                align
  2938.                dc.w  -8,14
  2939.                dc.l  0
  2940.                dc.l  swtext
  2941.                dc,l  0
  2942.        
  2943.         swtext:
  2944.                dc.b  "Switch",0
  2945.                align
  2946.  
  2947.         image:
  2948.                dc.w  0,0
  2949.                dc.w  32,13
  2950.                dc.w  1
  2951.                dc.l  imgdata
  2952.                dc.b  2,1
  2953.                dc.l  0
  2954.  
  2955.         image2:
  2956.                dc.w  0,0
  2957.                dc.w  32,13
  2958.                dc.w  1
  2959.                dc.l  imgdata2
  2960.                dc.b  2,1
  2961.                dc.l  0
  2962.  
  2963.         imgdata:
  2964.                dc.l 0
  2965.                dc.l %00000000011100000000000000000000
  2966.                dc.l %00000000111110000011101001000000
  2967.                dc.l %00000000111110000010101101000000
  2968.                dc.l %00000000011110000010101011000000
  2969.                dc.l %00000000000111000011101001000000
  2970.                dc.l %00000000000011100000000000000000
  2971.                dc.l %00000000000001110000000000000000
  2972.                dc.l %00000000000111111111100000000000
  2973.                dc.l %00000000001111111111110000000000
  2974.                dc.l %00000000001111111111110000000000
  2975.                dc.l %00000000000110000001100000000000
  2976.                dc.l 0
  2977.  
  2978.         imgdata2:
  2979.                dc.l 0
  2980.                dc.l %00000000000000000000111000000000
  2981.                dc.l %00011101110111000001111100000000
  2982.                dc.l %00010101000100000001111100000000
  2983.                dc.l %00010101100110000001111000000000
  2984.                dc.l %00011101000100000011100000000000
  2985.                dc.l %00000000000000000111000000000000
  2986.                dc.l %00000000000000001110000000000000
  2987.                dc.l %00000000000111111111100000000000
  2988.                dc.l %00000000001111111111110000000000
  2989.                dc.l %00000000001111111111110000000000
  2990.                dc.l %00000000000110000001100000000000
  2991.                dc.l 0
  2992.  
  2993.         gadget2:
  2994.                dc.l  0
  2995.                dc.w  150,30,100,50
  2996.                dc.w  5
  2997.                dc.w  2
  2998.                dc.w  3                   ;prop.gadet
  2999.                dc.l  mover               ;border
  3000.                dc.l  0,0,0
  3001.                dc.l  specinfo
  3002.                dc.w  3
  3003.                dc.l  0
  3004.  
  3005.         specinfo:
  3006.                dc.w  6                   ;flags:free horiz
  3007.                dc.w  0,0
  3008.                dc.w  $ffff/10,$ffff/5
  3009.                dc.w  0,0,0,0,0,0
  3010.  
  3011.         mover:
  3012.                dc.w  0,0,16,7
  3013.                dc.w  1
  3014.                dc.l  moverdata
  3015.                dc.b  1,0
  3016.                dc.l  0
  3017.  
  3018.         moverdata:
  3019.                dc.w %0111111111111110
  3020.                dc.w %0101111111111010
  3021.                dc.w %0101011111101010
  3022.                dc.w %0101010110101010
  3023.                dc.w %0101011111101010
  3024.                dc.w %0101111111111010
  3025.                dc.w %0111111111111110
  3026.  
  3027.         menu:blk.w  500
  3028.  
  3029.                end
  3030.                
  3031.                
  3032.  
  3033.  
  3034.       Chapter 8.
  3035.       ----------
  3036.       8.Advanced Programming.
  3037.       -----------------------
  3038.         You've learned a lot about machine language programming on the
  3039.         Amiga.What you need yet are a few routines that can be used as
  3040.         programming tools.We'll work on that right now.They'll be easy to 
  3041.         use in your own program.The sky's the limit now!
  3042.  
  3043.       8.1.Supervisor Mode.
  3044.       --------------------
  3045.         As mentioned in the chapter on the MC68000 processor,there are two
  3046.         operating modes:the User and the Supervisor mode.It is often
  3047.         necessary to move between the two modes.However,this isn't a
  3048.         simple process.
  3049.         The reason you want to do this,is that in User mode,you can't
  3050.         access the Status register.If you write to one of them,an
  3051.         Exception is executed which crashes the program.
  3052.  
  3053.         How can you get in Supervisor mode?
  3054.  
  3055.         No problem.The operating system of the Amiga contains a function
  3056.         in the EXEC library that lets you get into supervisor mode.Its
  3057.         called SuperState and it doesn't need any parameters.You can
  3058.         easily call this program by using the following lines:
  3059.  
  3060.         execbase    = 4                 ;exec base address
  3061.         superstate  =-150               ;turn on function
  3062.                ...
  3063.                move.l  execbase,a6      ;exec base address in A6
  3064.                jsr     superstate(a6)   ;turn on supervisor mode
  3065.                move.l  d0,savesp        ;save return value
  3066.                ...
  3067.         savesp:blk.l   1                ;space for sp value
  3068.  
  3069.         You get the value of the Stack Pointer(SP)back in the D0 register.
  3070.         You'll also find it in register A7,but this register is changed   
  3071.         regularly.The reason is that in Supervisor mode,the Amiga works
  3072.         with all the Interrupts and with the SP,and there are lots of     
  3073.         Interrupts for this computor.We'll talk about interrupts in a bit.
  3074.  
  3075.         After this call,you'll use the user stack instead of the
  3076.         supervisor stack.In this way,you can access the old user stack.You
  3077.         need to make sure that the user stack is large enough since the   
  3078.         interrupts must have enough room for their data on the stack.
  3079.         You need to save the value returned in D0,because you'll need this
  3080.         value later.You need to return to user mode sometime.Theres a
  3081.         function for this in the exec library as well.It is called the    
  3082.         UserState function.It needs one parameter,the SP value that comes 
  3083.         back from the SuperState function.
  3084.         Since you've saved this value in the long word starting at
  3085.         "savesp",you can write the following:
  3086.  
  3087.         userstate     =-156
  3088.                ...
  3089.                move.l  execbase,a6      ;exec base address in A6
  3090.                move.l  savesp,d0        ;put old sp in D0
  3091.                jsr     userstate(a6)    ;return to user mode
  3092.  
  3093.         Now you are back in the user mode.The user stack point(USP)is the 
  3094.         same as before.You can write functions that need to be run from
  3095.         the supervisor mode as subroutines.First you call superstate,save 
  3096.         the return value,execute the desired function,call userstate,and  
  3097.         end with a RTS command.If the USP was changed,the RTS command     
  3098.         would'nt work right,and the computor would jump who knows where
  3099.         and perhaps crash.Here it works though.
  3100.         Now comes the question:how does the operating system get the
  3101.         supervisor mode?Thats not too difficult;it goes like this:
  3102.  
  3103.         The superstate function attempts to access a Status Register.This 
  3104.         causes an Exception to occur and a routine is called whose address
  3105.         begins at the long word starting at $20.It is the Exception Vector
  3106.         for Privilege Violation.The routine that it branches to is called 
  3107.         in supervisor mode.Then it tests where this exception came from.If
  3108.         the routine finds that the exception comes from the superstate    
  3109.         routine whose address it knows,the matter is settled.It just
  3110.         branches to the routine without turning off the user mode.Thats
  3111.         all there is to it.
  3112.  
  3113.       8.2.Exception Programming.
  3114.       --------------------------
  3115.         The exceptions described in the processor chapter offer you a lot 
  3116.         of oppertunities to control the Amiga's functions.You can use them
  3117.         to specify how errors should be handled and even list a crash
  3118.         program.
  3119.  
  3120.         Here is a list of vectors that are used to jump to the exception  
  3121.         routines:
  3122.  
  3123.         Number      Address          Use with
  3124.         ------------------------------------------------------------------
  3125.           2         $008             Bus error
  3126.           3         $00C             Address eror
  3127.           4         $010             Illegal command
  3128.           5         $014             Division by zero
  3129.           6         $018             CHK command
  3130.           7         $01C             TRAPV command
  3131.           8         $020             Privilege Violation
  3132.           9         $024             Trace
  3133.          10         $028             Axxx command emulation
  3134.          11         $02C             Fxxx command emulation
  3135.                     $030-$038        Reserved
  3136.          15         $03C             Uninitialized interrupt
  3137.                     $040-$05F        Reserved
  3138.          24         $060             Unauthorised interrupt
  3139.         25-31       $064-$083        Level 1-7 interrupt
  3140.         32-47       $080-$0BF        TRAP commands
  3141.                     $0C0-$0FF        Reserved
  3142.         64-255      $100-$3FF        User interrupt vector
  3143.  
  3144.         Lets look at the TRAP commands as an example.They aren't used in
  3145.         the Amiga operating system.A TRAP command and a number between
  3146.         zero and fifteen are used to call one of the 16 posible TRAP
  3147.         routines.If the command TRAP #0 is executed,the processor (in
  3148.         supervisor mode)branches to the routine whose address lies at $80 
  3149.         in memory.This routine must end with a RTE(ReTurn from Exception) 
  3150.         command.
  3151.         Some operating systems,for example,the ATARI ST's TOS operating   
  3152.         systems,are completely callable via these TRAP's.Parameters are
  3153.         put on the stack,and then a TRAP command is executed.The advantage
  3154.         is that you don't have to know any of the operating systems
  3155.         addresses.In the Amiga you must know the addresses(Execbase=4).
  3156.  
  3157.         Lets write your own TRAP routine to demonstrate the use of the
  3158.         TRAP command.You'll need three program sections:
  3159.  
  3160.         1.The initialization of the TRAP vector.
  3161.         2.The TRAP routine itself(It must end with RTE).
  3162.         3.A test routine that calls the TRAP command.
  3163.  
  3164.         Initialization is very short:
  3165.  
  3166.         init:
  3167.                move.l  #trap0,$80        ;set vector for TRAP #0
  3168.                rts
  3169.  
  3170.         Now you need to write the trap0 routine.Lets use the example from 
  3171.         the hardware chapter that produced a beep.
  3172.         Lets write this routine using as little effort as possible.Change 
  3173.         the RTS to a RTE at the end,erase the line in which the loop
  3174.         counter D0 was loaded for the tone production,and change the loop 
  3175.         so that it works with long words.Now you can load the register
  3176.         with an arbitrary value and have the TRAP #0 followed by a peep of
  3177.         arbitrary duration.
  3178.  
  3179.         ;** beep tone production after a TRAP #0 **
  3180.  
  3181.         ctlw   =$dff096                  ;DMA control
  3182.         c0thi  =$dff0a0                  ;HI table address
  3183.         c0tlo  =c0thi+2                  ;LO table address
  3184.         c0tl   =c0thi+4                  ;table length
  3185.         c0per  =c0thi+6                  ;read in rate
  3186.         c0vol  =c0thi+8                  ;volume
  3187.  
  3188.         trap0:                           ;* produce a short peep
  3189.                move.l  #table,c0thi      ;table beginning
  3190.                move    #4,c0tl           ;table length
  3191.                move    #300,c0per        ;read in rate
  3192.                move    #40,c0vol         ;volume
  3193.                move    #$8201,ctlw       ;start DMA (sound)
  3194.  
  3195.         loop:
  3196.                subq.l  #1,d0             ;counter -1
  3197.                bne     loop              ;count dwn to zero
  3198.  
  3199.         still:
  3200.                move    #1,ctlw           ;turn on tone
  3201.                rte                       ;exception end
  3202.  
  3203.         table:                           ;sound table
  3204.                dc.b    -40,-70,-40,0,40,70,40,0
  3205.  
  3206.         You need to make sure that "table"is in CHIP RAM($00000-$7FFFF),
  3207.         otherwise the sound chip can't access the data!
  3208.  
  3209.         After entering this,you can test it out using the following
  3210.         routine:
  3211.  
  3212.         test:
  3213.                move.l  #$2ffff,d0        ;pass tone length in D0
  3214.                trap    #0                ;carry out exception:peep
  3215.                rts
  3216.  
  3217.         Now assemble both routines and start the initialization routine,  
  3218.         init.Nothing happens.
  3219.         Start the second routine,test.A beep that lasts about one second
  3220.         is output.
  3221.         One thing you must keep in mind is that if you change the program 
  3222.         and reassemble it,the address of the trap0 routine can change.    
  3223.         Before you execute the TRAP command,you must repeat the initializ-
  3224.         ation,so that the computor doesn't jump to the wrong location!               
  3225.         
  3226.  
  3227.  
  3228.  
  3229.       Appendices.
  3230.       -----------
  3231.       Overview of Library Functions.
  3232.       ------------------------------
  3233.         The following table gives you an overview of the available
  3234.         libraries and their functions.Each sublist of functions is
  3235.         preceded by the name of the library it is found in.
  3236.         These functions are listed with their negative offset in hex and  
  3237.         decimal.Their name and their parameters are also specified.The    
  3238.         parameter names are in parenthesis behind the function name.The   
  3239.         second set of parenthesis includes a list of registers that
  3240.         correspond to the parameter names.If no parameters are needed,we  
  3241.         put () to let you know.
  3242.  
  3243.  CLIST.LIBRARY
  3244.   -$001E  -30             InitCLPool (cLPool,size) (A0,D0)
  3245.   -$0024  -36             AllocCList (cLPool) (A1)
  3246.   -$002A  -42             FreeCList (cList) (A0)
  3247.   -$0030  -48             FlushCList (cList) (A0)
  3248.   -$0036  -54             SizeCList (cList) (A0)
  3249.   -$003C  -60             PutCLChar (cList,byte) (A0,D0)
  3250.   -$0042  -66             GetCLChar (cList) (A0)
  3251.   -$0048  -72             UnGetCLChar (cList,byte) (A0,D0)
  3252.   -$004E  -78             UpPutCLChar (cList) (A0)
  3253.   -$0054  -84             PutCLWord (cList,word) (A0,D0)
  3254.   -$005A  -90             GetCLWord (cList) (A0)
  3255.   -$0060  -96             UnGetCLWord (cList,word) (A0,D0)
  3256.   -$0066  -102            UnPutCLWord (cList) (A0)
  3257.   -$006C  -108            PutCLBuf (cList,buffer,length) (A0,A1,D1)
  3258.   -$0072  -114            GetCLBuf (cList,buffer,maxLength) (A0,A1,D1)
  3259.   -$0078  -120            MarkCList (cList,offset) (A0,D0)
  3260.   -$007E  -126            IncrCLMark (cList) (A0)
  3261.   -$0084  -132            PeekCLMark (cList) (A0)
  3262.   -$008A  -138            SplitCList (cList) (A0)
  3263.   -$0090  -144            CopyCList (cList) (A0)
  3264.   -$0096  -150            SubCList (cList,index,length) (A0,D0.D1)
  3265.   -$009C  -156            ConcatCList (sourceCList,destCList) (A0,A1)
  3266.  
  3267.  CONSOLE.LIBRARY
  3268.   -$002A  -42             CDInputHandler (events,device) (A0,A1)
  3269.   -$0030  -48             RawKeyConvert (events,buffer,length,keyMap)
  3270.                                         (A0,A1,D1,A2)
  3271.  DISKFONT.LIBRARY
  3272.   -$001E  -30             OpenDiskFont (textAttr) (A0)
  3273.   -$0024  -36             AvailFonts (buffer,bufBytes,flags) (A0,D0,D1)
  3274.  
  3275.  DOS.LIBRARY
  3276.   -$001e   -30            Open (name,access mode)(d1,d2)
  3277.   -$0024   -36            Close (file)(d1)
  3278.   -$002a   -42            Read (file,buffer,length)(d1,d2,d3)
  3279.   -$0030   -48            Write (file,buffer,length)(d1,d2,d3)
  3280.   -$0036   -54            Input()
  3281.   -$003c   -60            Output()
  3282.   -$0042   -66            Seek(file,position,offset)(d1,d2,d3)
  3283.   -$0048   -72            DeleteFile (name)(d1)
  3284.   -$004e   -78            Rename(oldname,newname)(d1,d2)
  3285.   -$0054   -84            Lock(name,type)(d1,d2)
  3286.   -$005a   -90            UnLock(lock)(d1)
  3287.   -$0060   -96            DupLock(lock)(d1)
  3288.   -$0066   -102           Examine(lock,fileinfoblock)(d1,d2)
  3289.   -$006c   -108           ExNext(lock,fileinfoblock)(d1,d2)
  3290.   -$0072   -114           Info(lock,parameterblock)(d1,d2)
  3291.   -$0078   -120           CreateDir(name)(d1)
  3292.   -$007e   -126           CurrentDir(lock)(d1)
  3293.   -$0084   -132           IoErr()
  3294.   -$008a   -138           CreateProc(name,pri,seglist,stacksize)(d1,d2,d3,d4)
  3295.   -$0090   -144           Exit(returncode)(d1)
  3296.   -$0096   -150           LoadSeg(filename)(d1)
  3297.   -$009c   -156           UnLoadSeg(segment)(d1)
  3298.   -$00a2   -162           Getpacket(wait)(d1)
  3299.   -$00a8   -168           Queuepacket(packet)(d1)
  3300.   -$00ae   -174           DeviceProc(name)(d1)
  3301.   -$00be   -180           SetComment(name,comment)(d1,d2)
  3302.   -$ooba   -186           SetProtection(name,mask)(d1,d2)
  3303.   -$00c0   -192           DateStamp(date)(d1)
  3304.   -$00c6   -198           Delay(timeout)(d1)
  3305.   -$00cc   -204           WaitForChar(file,timeout)(d1,d2)
  3306.   -$00d2   -210           ParentDir(lock)(d1)
  3307.   -$00d8   -216           IsInteractive(file)(d1)
  3308.   -$00de   -222           Execute(string,file,file)(d1,d2,d3)
  3309.  
  3310.  EXEC.LIBRARY
  3311.   -$001e   -30            Supervisor()
  3312.   -$0024   -36            ExitIntr()
  3313.   -$002a   -42            Schedule()
  3314.   -$0030   -48            Reschedule()
  3315.   -$0036   -54            Switch()
  3316.   -$003c   -60            Dispatch()
  3317.   -$0042   -66            Exception()
  3318.   -$0048   -72            InitCode(startclass,version)(d0,d1)
  3319.   -$004e   -78            InitStruct(inittable,memory,size)(a1,a2,d0)
  3320.   -$0054   -84            MakeLibrary(funcinit,structinit,libinit,datasize,
  3321.                           codesize)(a0,a1,a2,d0,d1)
  3322.   -$005a   -90            MakeFunctions(target,functionarray,funcdispbase)
  3323.                           (a0,a1,a2)
  3324.   -$0060   -96            FindResident(name)(a1)
  3325.   -$0066   -102           InitResident(resident,seglist)(a1,d1)
  3326.   -$006c   -108           Alert(alertnum,parameters)(d7,a5)
  3327.   -$0072   -114           Debug()
  3328.   -$0078   -120           Disable()
  3329.   -$007e   -126           Enable()
  3330.   -$0084   -132           Forbid()
  3331.   -$008a   -138           Permit()
  3332.   -$0090   -144           SetSR(newsr,mask)(d0,d1)
  3333.   -$0096   -150           SuperState()
  3334.   -$009c   -156           UserState(sysstack)(d0)
  3335.   -$00a2   -162           setIntVector(intnumber,interrupt)(d0,d1)
  3336.   -$00a8   -168           AddIntServer(intnumber,interrupt)(d0,d1)
  3337.   -$00ae   -174           RemIntServer(intnumber,interrupt)(d0,d1)
  3338.   -$00b4   -180           Cause(interrup)(a1)
  3339.   -$00ba   -186           Allocate(freelist,bytesize)(a0,d0)
  3340.   -$00c0   -192           Deallocate(freelist,memoryblock,bytesize)(a0,a1,d0)
  3341.   -$00c6   -198           AllocMem(bytesize,requirements)(d0,d1)
  3342.   -$00cc   -204           AlloAbs(bytesize,location)(d0,a1)
  3343.   -$00d2   -210           FreeMem(memoryblock,bytesize)(a1,d0)
  3344.   -$00d8   -216           AvailMem(requirements)(d1)
  3345.   -$00de   -222           AllocEntry(entry)(a0)
  3346.   -$00e4   -228           FreeEntry(entry)(a0)
  3347.   -$00ea   -234           Insert(list,node,pred)(a0,a1,a2)
  3348.   -$00f0   -240           AddHead(list,node)(a0,a1)
  3349.   -$00f6   -246           AddTail(list,node)(a0,a1)
  3350.   -$00fc   -252           Remove(node)(a1)
  3351.   -$0102   -258           RemHead(list)(a0)
  3352.   -$0108   -264           RemTail(list)(a0)
  3353.   -$010e   -270           Enqueue(list,node)(a0,a1)
  3354.   -$0114   -276           FindName(list,name)(a0,a1)
  3355.   -$011a   -282           AddTask(task,initpc,finalpc)(a1,a2,a3)
  3356.   -$0120   -288           RemTask(task)(a1)
  3357.   -$0126   -294           FindTask(name)(a1)
  3358.   -$012c   -300           SetTaskPri(task,prority)(a1,d0)
  3359.   -$0132   -306           SetSignal(newsignals,signelset)(d0,d1)
  3360.   -$0138   -312           SetExcept(newsignals,signalset)(d0,d1)
  3361.   -$013e   -318           Wait(signalset)(d0)
  3362.   -$0144   -324           Signal(task,signalset)(a1,d0)
  3363.   -$014a   -330           AllocSignal(signalnum)(d0)
  3364.   -$0150   -336           FreeSignal(signalnum)(d0)
  3365.   -$0156   -342           AllocTrap(trapnum)(d0)
  3366.   -$015c   -348           FreeTrap(trapnum)(d0)
  3367.   -$0162   -354           AddPort(port)(a1)
  3368.   -$0168   -360           RemPort(port)(a1)
  3369.   -$016e   -366           PutMsg(port,message)(a0,a1)
  3370.   -$0174   -372           GetMsg(port)(a0)
  3371.   -$017a   -378           ReplyMsg(message)(a1)
  3372.   -$0180   -384           WaitPort(port)(a0)
  3373.   -$0186   -390           FindPort(name)(a1)
  3374.   -$018c   -396           AddLibrary(library)(a1)
  3375.   -$0192   -402           RemLibrary(library)(a1)
  3376.   -$0198   -408           OldOpenLibrary(libname)(a1)
  3377.   -$019e   -414           CloseLibrary(library)(a1)
  3378.   -$01a4   -420           Setfunction(library,funcoffset,funcentry)(a1,a0,d0)
  3379.   -$01aa   -426           SumLibrary(library)(a1)
  3380.   -$01b0   -432           AddDevice(device)(a1)
  3381.   -$01b6   -438           RemDevice(device)(a1)
  3382.   -$01bc   -444           OpenDevice(devname,unit,iorequest,flags)(a0,d0,a1
  3383.                           ,d1)
  3384.   -$01c2   -450           CloseDevice(iorequest)(a1)
  3385.   -$01c8   -456           DoIO(iorequest)(a1)
  3386.   -$01ce   -462           SendIO(iorequest)(a1)
  3387.   -$01d4   -468           CheckIO(iorequest)(a1)
  3388.   -$01da   -474           WaitIO(iorequest)(a1)
  3389.   -$01e0   -480           AbortIO(iorequest)(a1)
  3390.   -$01e6   -486           AddResource(resource)(a1)
  3391.   -$01ec   -492           RemResource(resource)(a1)
  3392.   -$01f2   -498           OpenResource(resname,version)(a1,d0)
  3393.   -$01f8   -504           RawIOInit()
  3394.   -$01fe   -510           RawMayGetChar()
  3395.   -$0204   -516           RawPutChar(char)(d0)
  3396.   -$020a   -522           RawDoFmt()(a0,a1,a2,a3)
  3397.   -$0210   -528           GetCC()
  3398.   -$0216   -534           TypeOfMem(address)(a1)
  3399.   -$021c   -540           Procedure(semaport,bidmsg)(a0,a1)
  3400.   -$0222   -546           Vacate(semaport)(a0)
  3401.   -$0228   -552           OpenLibrary(libname,version)(a1,d0)
  3402.  
  3403.  GRAPHICS.LIBRARY
  3404.   -$001e   -30            BltBitMap(scrbitmap,scrx,scry,destbitmap,destx,
  3405.                           desty,sizex,sizey,minterm,mask,tempa)
  3406.                           (a0,d0,d1,a1,d2,d3,d4,d5,d6,d7,a2)
  3407.   -$0024   -36            BltTemplate(source,scrx,scrmod,destrastport,destx,
  3408.                           desty,sixex,sizey)(a0,d0,d1,a1,d2,d3,d4,d5)
  3409.   -$002a   -42            ClearEOL(rastport)(a1)
  3410.   -$0030   -48            ClearScreen(rastport)(a1)
  3411.   -$0036   -54            TextLength(rastport,string,count)(a1,a0,d0)
  3412.   -$003c   -60            Text(rastport,string,count)(a1,a0,d0)
  3413.   -$0042   -66            SetFont(rastportid,textfont)(a1,a0)
  3414.   -$0048   -72            OpenFont(textattr)(a0)
  3415.   -$004e   -78            CloseFont(textfont)(a1)
  3416.   -$0054   -84            AskSoftStyle(rastport)(a1)
  3417.   -$005a   -90            SetSoftStyle(rastport,style,enable)(a1,d0,d1)
  3418.   -$0060   -96            AddBob(bob,rastport)(a0,a1)
  3419.   -$0066   -102           AddVSprite(vsprite,rastport)(a0,a1)
  3420.   -$006c   -108           DoCollision(rastport)(a1)
  3421.   -$0072   -114           DrawGList(rastport,viewport)(a1,a0)
  3422.   -$0078   -120           InitGels(dummyhead,dummytail,gelsinfo)(a0,a1,a2)
  3423.   -$007e   -126           InitMasks(vsprite)(a0)
  3424.   -$0084   -132           RemIBob(bob,rastport,viewport)(a0,a1,a2)
  3425.   -$008a   -138           RemVSprite(vsprite)(a0)
  3426.   -$0090   -144           SetCollision(type,routine,gelsinfo)(d0,a0,a1)
  3427.   -$0096   -150           SortGList(rastport)(a1)
  3428.   -$009c   -156           AddAnimObj(obj,animationkey,rastport)(a0,a1,a2)
  3429.   -$00a2   -162           Animate(animationkey,rastport)(a0,a1)
  3430.   -$00a8   -168           etGBuffers(animationobj,rastport,doublebuffer)(a0,
  3431.                           a1,d0)
  3432.   -$00ae   -174           InitGMasks(animationobj)(a0)
  3433.   -$00b4   -180           GelsFuncE()
  3434.   -$00ba   -186           GelsFuncF()
  3435.   -$00c0   -192           LoadRGB4(viewport,colurs,count)(a0,a1,d0)
  3436.   -$00c6   -198           InitRastPort(rastport)(a1)
  3437.   -$00cc   -204           InitVPort(viewport)(a0)
  3438.   -$00d2   -210           MrgCop(view)(a1)        
  3439.   -$00D8  -216            MakeVPort (view,viewPort) (A0,A1)
  3440.   -$00DE  -222            LoadView (view) (A1)
  3441.   -$00E4  -228            WaitBlit ()
  3442.   -$00EA  -234            SetRast (rastPort,color) (A1,D0)
  3443.   -$00F0  -240            Move (rastPort,x,y) (A1,D0,D1)
  3444.   -$00F6  -246            Draw (rastPort,x,y) (A1,D0,D1)
  3445.   -$00FC  -252            AreaMove (rastPort,x,y) (A1,D0,D1)
  3446.   -$0102  -258            AreaDraw (rastPort,x,y) (A1,D0,D1)
  3447.   -$0108  -264            AreaEnd (rastPort) (A1)
  3448.   -$010E  -270            WaitTOF ()
  3449.   -$0114  -276            QBlit (blit) (A1)
  3450.   -$011A  -282            InitArea (areaInfo,vectorTable,vectorTableSize)
  3451.                           (A0,A1,D0)
  3452.   -$0120  -288            SetRGB4 (viewPort,index,r,g,b) (A0,D0,D1,D2,D3)
  3453.   -$0126  -294            QBSBlit (blit) (A1)
  3454.   -$012C  -300            BltClear (memory,size,flags) (A1,D0,D1)
  3455.   -$0132  -306            RectFill (rastPort,xl,yl,xu,yu)
  3456.                           (A1,D0,D1,D2,D3)
  3457.   -$0138  -312            BltPattern (rastPort,ras,xl,yl,maxX,maxY,
  3458.                           fillBytes) (A1,A0,D0,D1,D2,D3,D4)
  3459.   -$013E  -318            ReadPixel (rastPort,x,y) (A1,D0,D1)
  3460.   -$0144  -324            WritePixel (rastPort,x,y) (A1,D0,D1)
  3461.   -$014A  -330            Flood (rastPort,mode,x,y) (A1,D2,D0,D1)
  3462.   -$0150  -336            PolyDraw (rastPort,count,polyTable) (A1,D0,A0)
  3463.   -$0156  -342            SetAPen (rastPort,pen) (A1,D0)
  3464.   -$015C  -348            SetBPen (rastPort,pen) (A1,D0)
  3465.   -$0162  -354            SetDrMd (rastPort,drawMode) (A1,D0)
  3466.   -$0168  -360            InitView (view) (A1)
  3467.   -$016E  -366            CBump (copperList) (A1)
  3468.   -$0174  -372            CMove (copperList,destination,data) (A1,D0,D1)
  3469.   -$017A  -378            CWait (copperList,x,y) (A1,D0,D10
  3470.   -$0180  -384            VBeamPos ()
  3471.   -$0186  -390            InitBitMap (bitMap,depth,width,height)
  3472.                           (A0,D0,D1,D2)
  3473.   -$018C  -396            ScrollRaster (rastPort,dX,dY,minx,miny,maxx,
  3474.                           maxy) (A1,D0,D1,D2,D3,D4,D5)
  3475.   -$0192  -402            WaitBOVP (viewPort) (A0)
  3476.   -$0198  -408            GetSprite (simpleSprite,num) (A0,D0)
  3477.   -$019E  -414            FreeSprite (num) (D0)
  3478.   -$01A4  -420            ChangeSprite (vp,simpleSprite,data) (A0,A1,A2)
  3479.   -$01AA  -426            MoveSprite (viewPort,simpleSprite,x,y)
  3480.                           (A0,A1,D0,D1)
  3481.   -$01B0  -432            LockLayerRom (layer) (A5)
  3482.   -$01B6  -438            UnlockLayerRom (layer) (A5)
  3483.   -$01BC  -444            SyncSBitMap (1) (A0)
  3484.   -$01C2  -450            CopySBitMap (11,12) (A0,A1)
  3485.   -$01C8  -456            OwnBlitter ()
  3486.   -$01CE  -462            DisownBlitter ()
  3487.   -$01D4  -468            InitTmpRas (tmpras,buff,size) (A0,A1,D0)
  3488.   -$01DA  -474            AskFont (rastPort,textAttr) (A1,A0)
  3489.   -$01E0  -480            AddFont (textFont) (A1)
  3490.   -$01E6  -486            RemFont (textFont) (A1)
  3491.   -$01EC  -492            AllocRaster (width,height) (D0,D1)
  3492.   -$01F2  -498            FreeRaster (planeptr,width,height) (A0,D0,D1)
  3493.   -$01F8  -504            AndRectRegion (rgn,rect) (A0,A1)
  3494.   -$01FE  -510            OrRectRegion (rgn,rect) (A0,A1)
  3495.   -$0204  -516            NewRegion ()
  3496.   -$020A  -522            ** reserved **
  3497.   -$0210  -528            ClearRegion (rgn) (A0)
  3498.   -$0216  -534            DisposeRegion (rgn) (A0)
  3499.   -$021C  -540            FreeVPortCopLists (viewPort) (A0)
  3500.   -$0222  -546            FreeCopList (coplist) (A0)
  3501.   -$0228  -552            ClipBlit (srcrp,srcX,srcY,destrp,destX,destY,
  3502.                           sizeX,sizeY,minterm) (A0,D0,D1,A1,D2,D3,D4,D5,D6)
  3503.   -$022E  -558            XorRectRegion (rgn,rect) (A0,A1)
  3504.   -$0234  -564            FreeCprList (cprlist) (A0)
  3505.   -$023A  -570            GetColorMap (entries) (D0)
  3506.   -$0240  -576            FreeColorMap (colormap) (A0)
  3507.   -$0246  -582            GetRGB4 (colormap,entry) (A0,D0)
  3508.   -$024C  -588            ScrollVPort (vp) (A0)
  3509.   -$0252  -594            UCopperListInit (copperlist,num) (A0,D0)
  3510.   -$0258  -600            FreeGBuffers (animationObj,rastPort,
  3511.                           doubleBuffer) (A0,A1,D0)
  3512.   -$025E  -606            BltBitMapRastPort (srcbm,srcx,srcy,destrp,
  3513.                           destX,destY,sizeX,sizeY,minter)
  3514.                           (A0,D0,D1,A1,D2,D3,D4,D5,D6)
  3515.  
  3516.  ICON.LIBRARY
  3517.   -$001E  -30             GetWBObject (name) (A0)
  3518.   -$0024  -36             PutWBObject (name,object) (A0,A1)
  3519.   -$002A  -42             GetIcon (name,icon,freelist) (A0,A1,A2)
  3520.   -$0030  -48             PutIcon (name,icon) (A0,A1)
  3521.   -$0036  -54             FreeFreeList (freelist) (A0)
  3522.   -$003C  -60             FreeWBOject (WBOject) (A0)
  3523.   -$0042  -66             AllocWBOject ()
  3524.   -$0048  -72             AddFreeList (freelist,mem,size) (A0,A1,A2)
  3525.   -$004E  -78             GetDiskObject (name) (A0)
  3526.   -$0054  -84             PutDiskObject (name,diskobj) (A0,A1)
  3527.   -$005A  -90             FreeDiskObj (diskobj) (A0)
  3528.   -$0060  -96             FindToolType (toolTypeArray,typeName) (A0.A1)
  3529.   -$0066  -102            MatchToolValue (typeString,value) (A0,A1)
  3530.   -$006C  -108            BumbRevision (newname,oldname) (A0,A1)
  3531.  
  3532.  INTUITION.LIBRARY
  3533.   -$001E  -30             OpenIntuition ()
  3534.   -$0024  -36             Intuition (ievent) (A0)
  3535.   -$002A  -42             AddGadget (AddPtr,Gadget,Position) (A0,A1,D0)
  3536.   -$0030  -48             ClearDMRequest (Window) (A0)
  3537.   -$0036  -54             ClearMenuStrip (Window) (A0)
  3538.   -$003C  -60             ClearPointer (Window) (A0)
  3539.   -$0042  -66             CloseScreen (Screen) (A0)
  3540.   -$0048  -72             CloseWindow (Window) (A0)
  3541.   -$004E  -78             CloseWorkbench ()
  3542.   -$0054  -84             CurrentTime (Seconds,Micros) (A0,A1)
  3543.   -$005A  -90             DisplayAlert (AlertNumber,String,Height)
  3544.                           (D0,A0,D1)
  3545.   -$0060  -96             DiplayBeep (Screen) (A0)
  3546.   -$0066  -102            DoubleClick (sseconds,smicros,cseconds,
  3547.                           cmicros) (D0,D1,D2,D3)
  3548.   -$006C  -108            DrawBorder (Rport,Border,LeftOffset,TopOffset)
  3549.                           (A0,A1,D0,D1)
  3550.   -$0072  -114            DrawImage (RPort,Image,LeftOffset,TopOffset)
  3551.                           (A0,A1,D0,D1)
  3552.   -$0078  -120            EndRequest (requester,window) (A0,A1)
  3553.   -$007E  -126            GetDefPref (preferences,size) (A0,D0)
  3554.   -$0084  -132            GetPrefs (preferences,size) (A0,D0)
  3555.   -$008A  -138            InitRequester (req) (A0)
  3556.   -$0090  -144            ItemAddress (MenuStrip,MenuNumber) (A0,D0)
  3557.   -$0096  -150            ModifyIDCMP (Window,Flags) (A0,D0)
  3558.   -$009C  -156            ModifyProp (Gadget,Ptr,Reg,Flags,HPos,VPos,
  3559.                           HBody,VBody) (A0,A1,A2,D0,D1,D2,D3,D4)
  3560.   -$00A2  -162            MoveScreen (Screen,dx,dy) (A0,D0,D1)
  3561.   -$00A8  -168            MoveWindow (Window,dx,dy) (A0,D0,D1)
  3562.   -$00AE  -174            OffGadget (Gadget,Ptr,Req) (A0,A1,A2)
  3563.   -$00B4  -180            OffMenu (Window,MenuNumber) (A0,D0)
  3564.   -$00BA  -186            OnGadget (Gadget,Ptr,Req) (A0,A1,A2)
  3565.   -$00C0  -192            OnMenu (Window,MenuNumber) (A0,D0)
  3566.   -$00C6  -198            OpenScreen (OSArgs) (A0)
  3567.   -$00CC  -204            OpenWindow (OWArgs) (A0)
  3568.   -$00D2  -210            OpenWorkBench ()
  3569.   -$00D8  -216            PrintIText (rp,itext,left,top) (A0,A1,D0,D1)
  3570.   -$00DE  -222            RefreshGadgets (Gadgets,Ptr,Req) (A0,A1,A2)
  3571.   -$00E4  -228            RemoveGadgets (RemPtr,Gadget) (A0,A1)
  3572.   -$00EA  -234            ReportMouse (Window,Boolean) (A0,D0)
  3573.   -$00F0  -240            Request (Requester,Window) (A0,A1)
  3574.   -$00F6  -246            ScreenToBack (Screen) (A0)
  3575.   -$00FC  -252            SCreenToFront (Screen) (A0)
  3576.   -$0102  -258            SetDMRequest (Window,req) (A0,A1)
  3577.   -$0108  -264            SetMenuStrip (Window,Menu) (A0,A1)
  3578.   -$010E  -270            SetPointer (Window,Pointer,Height,Width,
  3579.                           XOFFset, YOFFset) (A0,A1,D0,D1,D2,D3)
  3580.   -$0114  -276            SetWindowTitles (Window,windowTitle,
  3581.                           screenTitle) (A0,A1,A2)
  3582.   -$011A  -282            ShowTitle (Screen,ShowIt) (A0,D0)
  3583.   -$0120  -288            SizeWindow (Windowmdx,dy) (A0,D0,D1)
  3584.   -$0126  -294            ViewAddress ()
  3585.   -$012C  -300            ViewPortAddress (Window) (A0)
  3586.   -$0132  -306            WindowToBack (Window) (A0)
  3587.   -$0138  -312            WindowToFront (Window) (A0)
  3588.   -$013E  -318            WindowLimits (Window,minwidth,minheight,
  3589.                           maxwidth, maxheight) (A0,D0,D1,D2,D3)
  3590.   -$0144  -324            SetPrefs (preferences,size,flag) (A0,D0,D1)
  3591.   -$014A  -330            IntuiTextLength (itext) (A0)
  3592.   -$0150  -336            WBenchToBack ()
  3593.   -$0156  -342            WBenchToFront ()
  3594.   -$015C  -348            AutoRequest (Window,Body,PText,NText,PFlag,
  3595.                           NFlag,W,H) (A0,A1,A2,A3,D0,D1,D2,D3)
  3596.   -$0162  -354            BeginRefresh (Window) (A0)
  3597.   -$0168  -360            BuildSysRequest (Window,Body,PosText,NegText,
  3598.                           Flags,W,H) (A0,A1,A2,A3,D0,D1,D2)
  3599.   -$016E  -366            EndRefresh (Window,Complete) (A0,D0)
  3600.   -$0174  -372            FreeSysRequest (Window) (A0)
  3601.   -$017A  -378            MakeScreen (Screen) (A0)
  3602.   -$0180  -384            RemakeDisplay ()
  3603.   -$0186  -390            RethinkDisplay ()
  3604.   -$018C  -396            AllocRemember (RememberKey,Size,Flags) (A0,D0,D1)
  3605.   -$0192  -402            AlohaWorkBench (wbport) (A0)
  3606.   -$0198  -408            FreeRemember (RememberKey,ReallyForgot) (A0,D0)
  3607.   -$019E  -414            LockIBase (dontknow) (D0)
  3608.   -$01A4  -420            UnlockIBase (IBLock) (A0)
  3609.  
  3610.  LAYERS.LIBRARY
  3611.   -$001E  -30             InitLayers (li) (A0)
  3612.   -$0024  -36             CreateUpfrontLayer (li,bm,x0,y0,xl,yl,flags,
  3613.                           bm2) A0,A1,D0,D1,D2,D3,D4,A2)
  3614.   -$002A  -42             CreateBehindLayer (li,bm,x0,y0,xl,yl,flags,
  3615.                           bm2) (A0,A1,D0,D1,D2,D3,D3,A2)
  3616.   -$0030  -48             UpfrontLayer (li,layer) (A0,A1)
  3617.   -$0036  -54             BehindLayer (li,layer) (A0,A1)
  3618.   -$003C  -60             MoveLayer (li,layer,dx,dy) (A0,A1,D0,D1)
  3619.   -$0042  -66             SizeLayer (li,layer,dx,dy) (A0,A1,D0,D1)
  3620.   -$0048  -72             ScrollLayer (li,layer,dx,dy) (A0,A1,D0,D1)
  3621.   -$004E  -78             BeginUpdate (layer) (A0)
  3622.   -$0054  -84             EndUpdate (layer) (A0)
  3623.   -$005A  -90             DeleteLayer (li,layer) (A0,A1)
  3624.   -$0060  -96             LockLayer (li,layer) (A0,A1)
  3625.   -$0066  -102            UnlockLayer (li,layer) (A0,A1)
  3626.   -$006C  -108            LockLayers (li) (A0)
  3627.   -$0072  -114            UnlockLayers (li) (A0)
  3628.   -$0078  -120            LockLayerInfo (li) (A0)
  3629.   -$007E  -126            SwapBitRastPortClipRect (rp,cr) (A0,A1)
  3630.   -$0084  -132            WhichLayer (li,x,y) (A0,D0,D1)
  3631.   -$008A  -138            UnlockLayerInfo (li) (A0)
  3632.   -$0090  -144            NewLayerInfo ()
  3633.   -$0096  -150            DisposeLayerInfo (li) (A0)
  3634.   -$009C  -156            FattenLayerInfo (li) (A0)
  3635.   -$00A2  -162            ThinLayerInfo (li) (A0)
  3636.   -$00A8  -168            MoveLayerInfrontOf (layer_to_move,
  3637.                           layer_to_be_in_front_of) (A0,A1)
  3638.  
  3639.  MATHFFP.LIBRARY
  3640.   -$001E  -30             SPFix (float) (D0)
  3641.   -$0024  -36             SPFit (integer) (D0)
  3642.   -$002A  -42             SPCmp (leftFloat,right,Float) (D1,D0)
  3643.   -$0030  -48             SPTst (float) (D1)
  3644.   -$0036  -54             SPAbs (float) (D0)
  3645.   -$003C  -60             SPNeg (float) (D0)
  3646.   -$0042  -66             SPAdd (leftFloat,rightFloat) (D1,D0)
  3647.   -$0048  -72             SPSub (leftFloat,rightFloat) (D1,D0)
  3648.   -$004E  -78             SPMul (leftFloat,rightFloat) (D1,D0)
  3649.   -$0054  -84             SPDiv (leftFloat,rightFloat) (D1,D0)
  3650.  
  3651.  MATHIEEEDOUBBAS.LIBRARY
  3652.   -$001E  -30             IEEEDPFix (integer,integer) (D0,D1)
  3653.   -$0024  -36             IEEEDPFit (integer) (D0)
  3654.   -$002A  -42             IEEEDPCamp (integer,integer,integer,integer)
  3655.                           (D0,D1,D2,D3)
  3656.   -$0030  -48             IEEEDPTst (integer,integer) (D0,D1)
  3657.   -$0036  -54             IEEEDPAbs (integer,integer) (D0,D1)
  3658.   -$003C  -60             IEEEDPNeg (integer,integer) (D0,D1)
  3659.   -$0042  -66             IEEEDPAdd (integer,integer,integer,integer)
  3660.                           (D0,D1,D2,D3)
  3661.   -$0048  -72             IEEEDPSub (integer,integer,integer,integer)
  3662.                           (D0,D1,D2,D3)
  3663.   -$004E  -78             IEEEDPMul (integer,integer,integer,integer)
  3664.                           (D0,D1,D2,D3)
  3665.   -$0054  -84             IEEEDPDiv (integer,integer,integer,integer)
  3666.                           (D0,D1,D2,D3)
  3667.  
  3668.  MATHTRANS.LIBRARY
  3669.   -$001E  -30             SPAtan (float) (D0)
  3670.   -$0024  -36             SPSin (float) (D0)
  3671.   -$002A  -42             SPCos (float) (D0)
  3672.   -$0030  -48             SPTan (float) (D0)
  3673.   -$0036  -54             SPSincos (leftFloat,rightFloat) (D1,D0)
  3674.   -$003C  -60             SPSinh (float) (D0)
  3675.   -$0042  -66             SPCosh (float) (D0)
  3676.   -$0048  -72             SPTanh (float) (D0)
  3677.   -$004E  -78             SPExp (float) (D0)
  3678.   -$0054  -84             SPLog (float) (D0)
  3679.   -$005A  -90             SPPow (leftFloat,rightFloat) (D1,D0)
  3680.   -$0060  -96             SPSqrt (float) (D0)
  3681.   -$0066  -102            SPTieee (float) (D0)
  3682.   -$006C  -108            SPFieee (float) (D0)
  3683.   -$0072  -114            SPAsin (float) (D0)
  3684.   -$0078  -120            SPAcos (float) (D0)
  3685.   -$007E  -126            SPLog10 (float) (D0)
  3686.  
  3687.  POTGO.LIBRARY
  3688.   -$0006  -6              AllocPotBits (bits) (D0)
  3689.   -$000C  -12             FreePotBits (bits) (D0)
  3690.   -$0012  -18             WritePotgo (word,mask) (D0,D1)
  3691.  
  3692.  TIMER.LIBRARY
  3693.   -$002A  -42             AddTime (dest,src) (A0,A1)
  3694.   -$0030  -48             SubTime (dest,src) (A0,A1)
  3695.   -$0036  -54             CmpTime (dest,src) (A0,A1)
  3696.  
  3697.  TRANSLATOR.LIBRARY
  3698.   -$001E  -30             Translate (inputString,inputLength,
  3699.                           outputBuffer,bufferSize) (A0,D0,A1,D1)
  3700.  
  3701.  
  3702.  Abbreviations (symbols) used:
  3703.  
  3704.           label     A label or address
  3705.           reg       Register
  3706.           an        Address register n
  3707.           dn        Data register n
  3708.           source    source operand
  3709.           dest      destination operand
  3710.           <ea>      address of register
  3711.           #n        direct value
  3712.  
  3713.  
  3714.  GENERAL INSTRUCTIONS
  3715.  
  3716.           BCC   label         Conditional branch, depends on condition.
  3717.           BRA   label         Unconditional branch (Similar to JMP).
  3718.           BSR   label         Branch to subprogram. Return address is
  3719.                               deposited on the stack, RTS causes return to
  3720.                               that address.
  3721.           CHK   <ea>,dx       Check data register for limits, activate the
  3722.                               CHK instruction exception.
  3723.           DBCC  reg,label     Check condition, decrement on branch.
  3724.           JMP   label         Jump to address (Similar to BRA).
  3725.           JSR   label         Jump to a subroutine. Return address is deposited
  3726.                               on stack, RTS causes return to that address.
  3727.           NOP                 No operation.
  3728.           RESET               Reset peripherals (Caution!).
  3729.           RTE                 Return from exception.
  3730.           RTR                 Return with loading of flags.
  3731.           RTS                 Return from subroutine (After BSR or JSR).
  3732.           SCC   <ea>          Set a byte to -1 when condition is met.
  3733.           STOP                Stop processing (Caution!).
  3734.           TRAP  #n            Jump to an exception.
  3735.           TRAPV               Check overflow flag, then TRAPV exception.
  3736.  
  3737.  
  3738.  ARITHMETIC OPERATIONS WITH WHOLE NUMBERS
  3739.  
  3740.           ADD   source,dest   Binary addition.
  3741.           ADDA  source,an     Binary addition to an address register.
  3742.           ADDI  #n,<ea>       Addition with a constant.
  3743.           ADDQ  #n,<ea>       Fast addition of a constant which can be only
  3744.                               from 1 to 8.
  3745.           ADDX  source,dest   Addition with transfer in X flag.
  3746.           CLR   <ea>          Clear an operand.
  3747.           CMP   source,dest   Comparison of two operands.
  3748.           CMPA  <ea>,an       Comparison with an address register.
  3749.           CMPI  #n,<ea>       Comparison with a constant.
  3750.           CMPM  source,dest   Comparison of two memory operands.
  3751.           DIVS  source,dest   Sign-true division of a 32 bit destination by
  3752.                               a 16 bit source operand. The result of the
  3753.                               division is stored in the LO word of the
  3754.                               destination, the remainder in the HI word.
  3755.           DIVU  source,dest   Division without regard to sign, similar to DIVS.
  3756.           EXT   dn            Sign-true expansion to twice original size
  3757.                               (width) data unit.
  3758.           MULS  source,dest   Sign-true multiplication of two words into one
  3759.                               word.
  3760.           MULU  source,dest   Multiplication without regard to sign, similar
  3761.                               to MULS.
  3762.           NEG   <ea>          Negation of an operand (twos complement).
  3763.           SUB   source,dest   Binary subtraction.
  3764.           SUBA  <ea>,an       Binary subtraction from an address register.
  3765.           SUBI  #n,<ea>       Subtraction of a constant.
  3766.           SUBQ  #n,<ea>       Fast subtraction of a three bit constant.
  3767.           SUBX  source,dest   Subtraction with transfer in X flag.
  3768.           TST   <ea>          Test operand and set N and Z flag.
  3769.  
  3770.  
  3771.  BINARY CODED DECIMAL NUMBERS
  3772.  
  3773.           ABCD  source,dest   Addition of two binary coded decimal numbers.
  3774.           NBCD  source,dest   Negation of a binary coded decimal number
  3775.                               (nine complement).
  3776.           SBCD  source,dest   Subtraction of two binary coded decimal numbers.
  3777.  
  3778.  
  3779.  LOGICAL OPERATIONS
  3780.  
  3781.           AND   source,dest   Logic AND.
  3782.           ANDI  #n,<ea>       Logic AND with a constant.
  3783.           EOR   source,dest   Exclusive OR.
  3784.           EORI  #n,<ea>       Exclusive OR with a constant.
  3785.           NOT   <ea>          Inversion of an operand.
  3786.           OR    source,dest   Logic OR.
  3787.           ORI   #n,<ea>       Logic OR with a constant.
  3788.           TAS   <ea>          Check a byte and set bit 7.
  3789.  
  3790.  
  3791.  SINGLE BIT MANIPULATION
  3792.  
  3793.           BCHG  #n,<ea>       Change bit n(0 is changed to 1 and vice versa).
  3794.           BCLR  #n,<ea>       Clear bit n.
  3795.           BSET  #n,<ea>       Set bit n.
  3796.           BTST  #n,<ea>       Test bit n, result is desplayed in Z flag.
  3797.  
  3798.  
  3799.  SHIFT AND ROTATE OPERANDS
  3800.  
  3801.           NOTE: n indicates a register, # indicates a direct value which
  3802.                 specifies the number of shiftings.
  3803.  
  3804.           AS    n,<ea>        Arithmetic shift to the left (*2^n)
  3805.           ASR   n,<ea>        Arithmetic shift to the right (/2^n)
  3806.           LSL   n,<ea>        Logic shift to the left.
  3807.           LSR   n,<ea>        Logic shift to the right.
  3808.           ROL   n,<ea>        Rotation left.
  3809.           ROR   n,<ea>        Rotation right.
  3810.           ROXL  n,<ea>        Rotation left with transfer in X flag.
  3811.           ROXR  n,<ea>        Rotation right with transfer in X flag.
  3812.  
  3813.  
  3814.  MOVE DATA INSTRUCTIONS
  3815.  
  3816.           EXG   rn,rn         Exchange two register contents (don't confuse
  3817.                               with swap!).
  3818.           LEA   <ea>,an       Load an effective address in address register an.
  3819.           LINK  an,#n         Build stack range.
  3820.           MOVE  source,dest   Carry value over from source to destination.
  3821.           MOVE  SR,<ea>       Transfer the status register contents.
  3822.           MOVE  <ea>,SR       Transfer the status register contents.
  3823.           MOVE  USP,<ea>      Transfer the user stack pointer.
  3824.           MOVE  <ea>,USP      Transfer the user stack pointer.
  3825.           MOVEA <ea>,an       Transfer a value to the address register an.
  3826.           MOVEM regs,<ea>     Transfer several registers at once.
  3827.           MOVEM <ea>,regs     Transfer several registers at once.
  3828.           MOVEP source,dest   Transfer data to peripherals.
  3829.           MOVEQ #n,dn         Quickly transfer an eight bit constant to the
  3830.                               data register dn.
  3831.           PEA   <ea>          Deposit an address on the stack.
  3832.           SWAP  dn            Swap the halves of the register (the upper 16 bit
  3833.                               with the lower).
  3834.           UNLK  an            Unlink the stack.
  3835.  
  3836.  
  3837.                           --=End of Book=--          
  3838.                           
  3839. LSD greetings go to; DEE JAY (well done and thanx!), RAZOR BLADE (Mr Abacus!), 
  3840. RYGAR, SCOOTER, and all docs fans everywhere!  
  3841.                          
  3842.